Skip to content

Commit

Permalink
dockerfile test
Browse files Browse the repository at this point in the history
  • Loading branch information
ginokok1996 committed Nov 5, 2021
1 parent 226674e commit 1d7f5f1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 89 deletions.
86 changes: 42 additions & 44 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
54 changes: 9 additions & 45 deletions pwa/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1d7f5f1

Please sign in to comment.