Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: E2E Tests

permissions:
contents: read
issues: write
pull-requests: write

on:
push:
branches: [main]
issue_comment:
types: [created]

jobs:
e2e:
runs-on: ubuntu-latest
# Run on push/PR or when a maintainer comments "/test e2e" or "/run e2e"
if: |
github.event_name != 'issue_comment' || (
github.event.issue.pull_request &&
(contains(github.event.comment.body, '/test e2e') || contains(github.event.comment.body, '/run e2e')) &&
(github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR')
)

steps:
- name: Checkout code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
with:
# When triggered by comment, checkout the PR branch
ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || github.ref }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435

- name: Set up Docker Compose
uses: docker/setup-compose-action@364cc21a5de5b1ee4a7f5f9d3fa374ce0ccde746

- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Configure Git for CI
run: |
git config --global user.name "CI Runner"
git config --global user.email "ci@example.com"
git config --global init.defaultBranch main

- name: Build and start services with Docker Compose
run: docker compose up -d --build

- name: Wait for services to be ready
run: |
timeout 60 bash -c 'until docker compose ps | grep -q "Up"; do sleep 2; done'
sleep 10

- name: Run E2E tests
run: npm run test:e2e

- name: Stop services
if: always()
run: docker compose down -v
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM node:20 AS builder

USER root

WORKDIR /app

COPY tsconfig.json tsconfig.publish.json proxy.config.json config.schema.json test-e2e.proxy.config.json vite.config.ts package*.json index.html index.ts ./
COPY src/ /app/src/
COPY public/ /app/public/

# Build the UI and server
RUN npm pkg delete scripts.prepare \
&& npm ci --include=dev \
&& npm run build-ui -dd \
&& npx tsc --project tsconfig.publish.json \
&& cp config.schema.json dist/ \
&& npm prune --omit=dev

FROM node:20 AS production

COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules/ /app/node_modules/
COPY --from=builder /app/dist/ /app/dist/
COPY --from=builder /app/build /app/dist/build/
COPY proxy.config.json config.schema.json ./
COPY docker-entrypoint.sh /docker-entrypoint.sh

USER root

RUN apt-get update && apt-get install -y \
git tini \
&& rm -rf /var/lib/apt/lists/*

RUN chown 1000:1000 /app/dist/build \
&& chmod g+w /app/dist/build

USER 1000

WORKDIR /app

EXPOSE 8080 8000

ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
CMD ["node", "dist/index.js"]
59 changes: 59 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
services:
git-proxy:
build: .
ports:
- '8000:8000'
- '8081:8081'
command: ['node', 'dist/index.js', '--config', '/app/test-e2e.proxy.config.json']
volumes:
- ./test-e2e.proxy.config.json:/app/test-e2e.proxy.config.json:ro
# If using Podman, you might need to add the :Z or :z option for SELinux
# - ./test-e2e.proxy.config.json:/app/test-e2e.proxy.config.json:ro,Z
depends_on:
- mongodb
- git-server
networks:
- git-network
environment:
- NODE_ENV=test
- GIT_PROXY_UI_PORT=8081
- GIT_PROXY_SERVER_PORT=8000
- NODE_OPTIONS=--trace-warnings
- NODE_TLS_REJECT_UNAUTHORIZED=0
# Runtime environment variables for UI configuration
# API_URL should point to the same origin as the UI (both on 8081)
# Leave empty or unset for same-origin API access
# - API_URL=
# CORS configuration - controls which origins can access the API
# Options:
# - '*' = Allow all origins (testing/development)
# - Comma-separated list = 'http://localhost:3000,https://example.com'
# - Unset/empty = Same-origin only (most secure)
- ALLOWED_ORIGINS=
mongodb:
image: mongo:7
ports:
- '27017:27017'
networks:
- git-network
environment:
- MONGO_INITDB_DATABASE=gitproxy
volumes:
- mongodb_data:/data/db

git-server:
build: localgit/
ports:
- '8443:8443' # HTTPS git server
environment:
- GIT_HTTP_EXPORT_ALL=true
networks:
- git-network
hostname: git-server

networks:
git-network:
driver: bridge

volumes:
mongodb_data:
20 changes: 20 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# Use runtime environment variables (not VITE_* which are build-time only)
# API_URL can be set at runtime to override auto-detection
# ALLOWED_ORIGINS can be set at runtime for CORS configuration
cat > /app/dist/build/runtime-config.json << EOF
{
"apiUrl": "${API_URL:-}",
"allowedOrigins": [
"${ALLOWED_ORIGINS:-*}"
],
"environment": "${NODE_ENV:-production}"
}
EOF

echo "Created runtime configuration with:"
echo " API URL: ${API_URL:-auto-detect}"
echo " Allowed Origins: ${ALLOWED_ORIGINS:-*}"
echo " Environment: ${NODE_ENV:-production}"

exec "$@"
30 changes: 30 additions & 0 deletions localgit/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM httpd:2.4

RUN apt-get update && apt-get install -y \
git \
apache2-utils \
python3 \
openssl \
&& rm -rf /var/lib/apt/lists/*

COPY httpd.conf /usr/local/apache2/conf/httpd.conf
COPY git-capture-wrapper.py /usr/local/bin/git-capture-wrapper.py
COPY generate-cert.sh /usr/local/bin/generate-cert.sh

RUN chmod +x /usr/local/bin/generate-cert.sh \
&& /usr/local/bin/generate-cert.sh

RUN htpasswd -cb /usr/local/apache2/conf/.htpasswd admin admin123 \
&& htpasswd -b /usr/local/apache2/conf/.htpasswd testuser user123

COPY init-repos.sh /usr/local/bin/init-repos.sh

RUN chmod +x /usr/local/bin/init-repos.sh \
&& chmod +x /usr/local/bin/git-capture-wrapper.py \
&& mkdir -p /var/git-captures \
&& chown www-data:www-data /var/git-captures \
&& /usr/local/bin/init-repos.sh

EXPOSE 8443

CMD ["httpd-foreground"]
Loading
Loading