Skip to content

Commit 425f69a

Browse files
committed
testing builds
1 parent a8ea5ed commit 425f69a

File tree

7 files changed

+81
-64
lines changed

7 files changed

+81
-64
lines changed

.github/workflows/playwright.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,21 @@ jobs:
3434
runs-on: ubuntu-latest
3535
steps:
3636
- uses: actions/checkout@v4
37-
- uses: actions/setup-node@v4
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v3
39+
- name: Build and export to Docker
40+
uses: docker/build-push-action@v6
3841
with:
39-
node-version: lts/*
40-
- name: Install Playwright
41-
run: npm install -g @playwright/test
42+
load: true
43+
tags: api:test
4244
- name: Run Playwright tests
43-
run: docker compose --profile tests run playwright
45+
run: docker run -it --rm --name playwright \
46+
-v $(pwd)/test-results-docker-org:/test-results \
47+
-e VUE_APP_SCOPE=organization \
48+
-e VUE_APP_GITHUB_ORG=octodemo \
49+
-e VUE_APP_GITHUB_API=/api/github \
50+
-e APP_MOCKED_DATA=true \
51+
api:test @org
4452
- uses: actions/upload-artifact@v4
4553
if: ${{ !cancelled() }}
4654
with:
@@ -53,13 +61,21 @@ jobs:
5361
runs-on: ubuntu-latest
5462
steps:
5563
- uses: actions/checkout@v4
56-
- uses: actions/setup-node@v4
64+
- name: Set up Docker Buildx
65+
uses: docker/setup-buildx-action@v3
66+
- name: Build and export to Docker
67+
uses: docker/build-push-action@v6
5768
with:
58-
node-version: lts/*
59-
- name: Install Playwright
60-
run: npm install -g @playwright/test
69+
load: true
70+
tags: api:test
6171
- name: Run Playwright tests
62-
run: docker compose -f docker-compose.yml -f docker-compose.ent.override.yml --profile tests run playwright
72+
run: docker run -it --rm --name playwright \
73+
-v $(pwd)/test-results-docker-ent:/test-results \
74+
-e VUE_APP_SCOPE=enterprise \
75+
-e VUE_APP_GITHUB_ENT=octodemo \
76+
-e VUE_APP_GITHUB_API=/api/github \
77+
-e APP_MOCKED_DATA=true \
78+
api:test @ent
6379
- uses: actions/upload-artifact@v4
6480
if: ${{ !cancelled() }}
6581
with:

api.Dockerfile

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
# Stage 1: Build the Vue.js application
2+
# mode can be 'prod' - default or 'playwright'
3+
# for 'playwright' mode, the final image will be base-playwright
4+
# for 'prod' mode, the final image will be base-prod
5+
# build with 'docker build -f api.Dockerfile -t api --build-arg mode=playwright .'
6+
# build with 'docker build -f api.Dockerfile -t api .' for production
7+
ARG mode=prod
8+
29
FROM node:23 AS build-stage
310

411
USER node
512
WORKDIR /app
613

714
COPY --chown=1000:1000 package*.json ./
8-
RUN npm install
15+
RUN npm ci
916
COPY --chown=1000:1000 . .
1017
RUN npm run build
1118

1219
# Stage 2: Prepare the Node.js API
13-
FROM node:23 AS api-stage
20+
FROM node:23 AS base-prod
1421

1522
WORKDIR /api
1623

1724
# Copy package.json and other necessary files for the API
1825
COPY --chown=1000:1000 api/package*.json ./
19-
RUN npm install && \
26+
RUN npm ci && \
2027
chown -R 1000:1000 /api && \
2128
apt-get update && \
2229
apt-get install -y --no-install-recommends gettext-base && \
@@ -38,4 +45,29 @@ EXPOSE 3000
3845
RUN chmod +x /api/docker-entrypoint.api/entrypoint.sh
3946

4047
USER node
41-
ENTRYPOINT ["/api/docker-entrypoint.api/entrypoint.sh"]
48+
ENTRYPOINT ["/api/docker-entrypoint.api/entrypoint.sh"]
49+
50+
#-----------------------------------
51+
FROM mcr.microsoft.com/playwright:v1.49.1 AS base-playwright
52+
53+
WORKDIR /pw
54+
55+
RUN apt-get update && \
56+
apt-get install -y --no-install-recommends gettext-base && \
57+
apt-get clean && \
58+
rm -rf /var/lib/apt/lists/*
59+
60+
COPY --chown=1000:1000 --from=base-prod /api /api
61+
COPY --chown=1000:1000 --from=base-prod /mock-data /mock-data
62+
COPY --chown=1000:1000 tests ./tests
63+
COPY --chown=1000:1000 playwright.config.ts .
64+
COPY --chown=1000:1000 playwright.docker.config.ts .
65+
66+
67+
RUN npm install @playwright/[email protected]
68+
# RUN npx playwright install --with-deps
69+
70+
ENTRYPOINT [ "npx", "playwright", "test", "-c", "playwright.docker.config.ts", "--output", "/test-results", "--grep"]
71+
72+
#-----------------------------------
73+
FROM base-${mode} AS final

api/server.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import axios from 'axios';
55
import { fileURLToPath } from 'url';
66
import session from 'express-session';
77
import { createProxyMiddleware } from 'http-proxy-middleware';
8+
import { readFileSync } from 'fs';
89

910
// Construct __dirname equivalent in ES module scope
1011
const __dirname = path.dirname(fileURLToPath(import.meta.url));

docker-compose.ent.override.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

docker-compose.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playwright.docker.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { defineConfig } from '@playwright/test';
2+
import baseConfig from './playwright.config';
3+
4+
export default defineConfig({
5+
...baseConfig,
6+
use: {
7+
baseURL: 'http://127.0.0.1:3000',
8+
},
9+
webServer: {
10+
command: '/api/docker-entrypoint.api/entrypoint.sh',
11+
url: 'http://127.0.0.1:3000',
12+
reuseExistingServer: false,
13+
cwd: '/api',
14+
stderr: 'pipe',
15+
stdout: 'pipe'
16+
},
17+
});

0 commit comments

Comments
 (0)