forked from ruxailab/RUXAILAB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile-playwright
More file actions
58 lines (45 loc) · 1.58 KB
/
Dockerfile-playwright
File metadata and controls
58 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Etapa 1: Construcción
FROM node:lts AS build-stage
WORKDIR /app
# Copiar y instalar dependencias
COPY package*.json ./
RUN npm ci
# Copiar el resto de la aplicación y construir
COPY babel.config.js ./
COPY vue.config.js ./
COPY .env ./
COPY public ./public
COPY src ./src
RUN npm run build-dev
# Etapa 2: Producción y Pruebas
FROM node:20
WORKDIR /app
# Instalar 'serve' y 'wait-on' para servir la aplicación y esperar a que esté lista
RUN npm install -g serve wait-on
# Crear usuario no root para ejecución
RUN useradd -m -u 1001 app
ENV PLAYWRIGHT_BROWSERS_PATH=/home/app/.cache/ms-playwright
RUN mkdir -p /home/app/.cache/ms-playwright
# Copiar la aplicación construida desde la etapa de construcción
COPY --from=build-stage /app/dist /app
# Copiar y instalar dependencias necesarias para Playwright
COPY package*.json ./
RUN npx playwright install --with-deps
RUN npm install @playwright/test -D
RUN chown -R app:app /home/app/.cache/ms-playwright
# Copiar la configuración de Playwright y el resto de la aplicación
COPY playwright.config.js .
COPY playwright.config.ts .
COPY e2e ./e2e
COPY tests ./tests
COPY src ./src
COPY public ./public
COPY babel.config.js ./
COPY vue.config.js ./
RUN mkdir -p /app/playwright/output /app/playwright-report && chown -R app:app /app/playwright /app/playwright-report
RUN chown -R app:app /app
# Exponer el puerto en el que se servirá la aplicación
EXPOSE 5000
USER app
# Ejecutar la aplicación y esperar a que esté disponible antes de ejecutar las pruebas
CMD ["sh", "-c", "serve -s . -l 5000 & wait-on http://localhost:5000 && npx playwright test"]