From 1d7f5f1c744dc40706db5a72cb28a844c38fffcc Mon Sep 17 00:00:00 2001 From: ginokok1996 Date: Fri, 5 Nov 2021 09:46:18 +0100 Subject: [PATCH] dockerfile test --- docker-compose.yml | 86 ++++++++++++++++++++++------------------------ pwa/Dockerfile | 54 +++++------------------------ 2 files changed, 51 insertions(+), 89 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9371af2..3d8228d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,54 +5,52 @@ services: &pwa image: ${CONTAINER_REGISTRY_BASE}/${CONTAINER_PROJECT_NAME}:${APP_BUILD} build: pwa - depends_on: - - php - ports: - - "81:8000" - - php: - &php - image: ghcr.io/conductionnl/commonground-gateway-php:dev - depends_on: - - db - volumes: - - ./gateway:/srv/api/fixtures:rw,cached - - ./certs:/var/certs:rw,cached - environment: - #- DATABASE_URL=postgres://api-platform:!ChangeMe!@db/api?serverVersion=10.1 - - DATABASE_URL=mysql://api-platform:!ChangeMe!@db/api?serverVersion=10.1 - - AUTH_ENABLED=false - - REDIS_HOST=redis - - REDIS_PORT=6379 - - APP_REPRO=example - ports: - - "82:80" - - api: - &nginx - image: ghcr.io/conductionnl/commonground-gateway-nginx:latest - depends_on: - - php ports: - "80:80" - environment: - - NGINX_HOST=php - - NGINX_ENV=${APP_ENV} + +# php: +# &php +# image: ghcr.io/conductionnl/commonground-gateway-php:dev +# depends_on: +# - db +# volumes: +# - ./gateway:/srv/api/fixtures:rw,cached +# - ./certs:/var/certs:rw,cached +# environment: +# #- DATABASE_URL=postgres://api-platform:!ChangeMe!@db/api?serverVersion=10.1 +# - DATABASE_URL=mysql://api-platform:!ChangeMe!@db/api?serverVersion=10.1 +# - AUTH_ENABLED=false +# - REDIS_HOST=redis +# - REDIS_PORT=6379 +# - APP_REPRO=example +# ports: +# - "82:80" - db: - image: mysql:5.7 - environment: - - MYSQL_ROOT_PASSWORD=example - - MYSQL_DATABASE=api - - MYSQL_USER=api-platform - - MYSQL_PASSWORD=!ChangeMe! - volumes: - - db-mysql:/var/lib/mysql:rw - ports: - - "3366:3306" +# api: +# &nginx +# image: ghcr.io/conductionnl/commonground-gateway-nginx:latest +# depends_on: +# - php +# ports: +# - "80:80" +# environment: +# - NGINX_HOST=php +# - NGINX_ENV=${APP_ENV} - redis: - image: redis:4-alpine +# db: +# image: mysql:5.7 +# environment: +# - MYSQL_ROOT_PASSWORD=example +# - MYSQL_DATABASE=api +# - MYSQL_USER=api-platform +# - MYSQL_PASSWORD=!ChangeMe! +# volumes: +# - db-mysql:/var/lib/mysql:rw +# ports: +# - "3366:3306" +# +# redis: +# image: redis:4-alpine volumes: db-data: {} diff --git a/pwa/Dockerfile b/pwa/Dockerfile index e9d0bb5..3691a29 100644 --- a/pwa/Dockerfile +++ b/pwa/Dockerfile @@ -1,48 +1,12 @@ -# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage -# https://docs.docker.com/compose/compose-file/#target +FROM node:alpine as builder +WORKDIR /app -# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact -ARG NODE_VERSION=14 - -# "common" stage -FROM node:${NODE_VERSION}-alpine AS api_platform_pwa_common - -EXPOSE 8000 - -WORKDIR /usr/src/pwa - -ENV NEXT_TELEMETRY_DISABLED 1 -ENV NEXT_PUBLIC_ME_URL=${NEXT_PUBLIC_ME_URL} - -# prevent the reinstallation of node modules at every changes in the source code -COPY package.json yarn.lock ./ -RUN yarn - -COPY . ./ - -VOLUME /usr/src/pwa/node_modules - - -# "development" stage -# depends on the "common" stage above -FROM api_platform_pwa_common AS api_platform_pwa_dev - -ENV API_PLATFORM_CLIENT_GENERATOR_OUTPUT . -RUN yarn global add @api-platform/client-generator - -CMD ["yarn", "develop"] - - -# "build" stage -# depends on the "common" stage above -FROM api_platform_pwa_common AS api_platform_pwa_prod - -ENV NODE_ENV production -ARG NEXT_PUBLIC_ENTRYPOINT - -RUN set -eux; \ - yarn build - -CMD ["yarn", "develop"] +COPY package.json . +RUN npm install +COPY . . +RUN ["npm", "run", "build"] +FROM nginx +EXPOSE 80 +COPY --from=builder /app/public /usr/share/nginx/html