-
Notifications
You must be signed in to change notification settings - Fork 0
Mrc 6647 ci docker #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 25 commits
5f36112
45ec0a9
c0f6c4f
62ad3eb
f962a53
73b1503
60d8cae
7e4709d
49ba987
771a2d7
19b181e
fb03763
e758ef3
1f87db2
7282899
10f4fda
f1e5979
57f4051
fb72f72
65fa133
673b0ea
ae1d34b
7f69d81
3e8c929
e182685
34e110c
6ad185d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| Dockerfile | ||
| .dockerignore | ||
| .git | ||
| .gitignore | ||
| .gitattributes | ||
| README.md | ||
| .npmrc | ||
| .prettierrc | ||
| .eslintrc.cjs | ||
| .graphqlrc | ||
| .editorconfig | ||
| .svelte-kit | ||
| .vscode | ||
| node_modules | ||
| build | ||
| package | ||
| **/.env |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: build and push docker image | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - 'releases/*' | ||
| pull_request: | ||
| branches: | ||
| - '*' | ||
| env: | ||
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
| IMAGE_NAME: ghcr.io/mrc-ide/mint-frontend | ||
|
|
||
| jobs: | ||
| build-push: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Log in to GitHub Container Registry | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: | | ||
| ${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }} | ||
| ${{ env.BRANCH_NAME == 'main' && format('{0}:latest', env.IMAGE_NAME) || '' }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| name: test workflow | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - 'releases/*' | ||
| pull_request: | ||
| branches: | ||
| - '*' | ||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| node-version: [22.x] | ||
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| - name: Set up Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| cache-dependency-path: package-lock.json | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Run format + lint checks | ||
| run: npm run lint | ||
| - name: check svelte-check | ||
| run: npm run check | ||
| - name: Install Playwright Browsers | ||
| run: npx playwright install --with-deps | ||
| - name: Run unit tests | ||
| run: npm run test:unit:coverage | ||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| slug: mrc-ide/mint-v2 | ||
| fail_ci_if_error: true | ||
| e2e-tests: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| node-version: [22.x] | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| - name: Set up Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Start dependencies | ||
| run: ./scripts/run_dependencies.sh | ||
| - name: Install Playwright Browsers | ||
| run: npx playwright install --with-deps | ||
| - name: Run Playwright tests | ||
| run: npm run test:e2e | ||
| - name: Stop dependencies | ||
| if: ${{ always() }} | ||
| run: ./scripts/stop_dependencies.sh | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,4 @@ Thumbs.db | |
| # Vite | ||
| vite.config.js.timestamp-* | ||
| vite.config.ts.timestamp-* | ||
| coverage | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| FROM node:22-slim AS builder | ||
| WORKDIR /app | ||
| COPY package*.json ./ | ||
| RUN npm ci | ||
| COPY . . | ||
| RUN npm run build | ||
| RUN npm prune --omit=dev | ||
|
|
||
| FROM builder AS runtime | ||
| WORKDIR /app | ||
| COPY --from=builder /app/build build/ | ||
| COPY --from=builder /app/node_modules node_modules/ | ||
| COPY package.json . | ||
| EXPOSE 3000 | ||
| ENV NODE_ENV=production | ||
| CMD ["node", "build"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,3 +76,30 @@ npx shadcn-svelte@latest add [component-name] | |
| ``` | ||
|
|
||
| These components will be added to `src/lib/components/ui/` and automatically registered in the SvelteKit app. | ||
|
|
||
| ## Docker | ||
|
|
||
| #### Using Docker Compose | ||
|
|
||
| A `compose.yml` file is provided to run the application along with its dependencies (Redis and Mintr API). | ||
|
|
||
| 1. **Start services**: | ||
|
|
||
| ```sh | ||
| docker-compose up | ||
| ``` | ||
|
Comment on lines
+88
to
+90
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we also include
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not anymore because im using the image from ghcr and not building locally |
||
|
|
||
| 2. **Access the application**: | ||
| Wait for mint-frontend to be ready. Open your browser and navigate to `http://127.0.0.1:3000`. | ||
| 3. **Stop services**: | ||
|
|
||
| ```sh | ||
| docker-compose down | ||
|
||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| Environment variables can be set in a `.env` file in the root directory or added to the environment. Example variables include: | ||
|
|
||
| - `FRONTEND_REF`: Git reference for the frontend image (default: `main`) | ||
| - `API_REF`: Git reference for the Mintr API image (default: `main`) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| services: | ||
| mint-redis: | ||
| image: redis:8.0 | ||
| ports: | ||
| - 6379:6379 | ||
| volumes: | ||
| - mint-data:/data | ||
| container_name: mint-redis | ||
| mint-frontend: | ||
| image: ghcr.io/mrc-ide/mint-frontend:${FRONTEND_REF:-main} | ||
| pull_policy: always | ||
| ports: | ||
| - 127.0.0.1:3000:3000 | ||
| environment: | ||
| - REDIS_URL=redis://mint-redis:6379 | ||
| - PUBLIC_MINTR_URL=http://mintr:8888 | ||
| - ORIGIN=http://127.0.0.1:3000 | ||
| depends_on: | ||
| mint-redis: | ||
| condition: service_started | ||
| mintr: | ||
| condition: service_healthy | ||
| restart: true | ||
| mintr: | ||
| image: ghcr.io/mrc-ide/mintr:${API_REF:-main} | ||
| container_name: mintr | ||
| healthcheck: | ||
| test: curl -f http://localhost:8888/ || exit 1 | ||
| start_period: 1m | ||
| start_interval: 10s | ||
| interval: 1m | ||
| timeout: 30s | ||
| retries: 5 | ||
| ports: | ||
| - 8888:8888 | ||
| volumes: | ||
| mint-data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this? i remember its been on the ci for packit i think, but i dont think we actually needed this right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool have removed.. i just added because it was in the docker action docs