Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
fix: revert
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail2404 committed Dec 5, 2023
1 parent b6ef6db commit a2f4c00
Show file tree
Hide file tree
Showing 14 changed files with 874 additions and 0 deletions.
40 changes: 40 additions & 0 deletions server/Docker/app.e2e.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ARG COMPOSE_PROJECT_NAME
FROM ${COMPOSE_PROJECT_NAME}-cache as cache

FROM node:18 as build
ARG WORKDIR_FLOW
ARG COMPOSE_PROJECT_NAME
WORKDIR ${WORKDIR_FLOW}

COPY --from=cache /tmp/node_modules ./node_modules
COPY . .

RUN if [ ! -f .env ]; then cp ./env-example .env; fi
RUN sed -i -e 's/^DATABASE_HOST.*/DATABASE_HOST='${COMPOSE_PROJECT_NAME}'-postgres/' -e 's/^MAIL_HOST.*/MAIL_HOST='${COMPOSE_PROJECT_NAME}'-maildev/' .env

COPY ./package*.json .
COPY ./tsconfig.build.json .

RUN yarn run build && ls dist

FROM node:18-alpine as release
MAINTAINER Pikj [Jreydman] Reyderman <[email protected]>

ARG WORKDIR_FLOW
ARG APP_PORT
WORKDIR ${WORKDIR_FLOW}

COPY --from=build ${WORKDIR_FLOW} .
#COPY --from=build ${WORKDIR_FLOW}/node_modules ./node_modules
#COPY --from=build ${WORKDIR_FLOW}/.env .
#COPY --from=build ${WORKDIR_FLOW}/dist ./dist
#COPY --from=build ${WORKDIR_FLOW}/package*.json .

EXPOSE ${APP_PORT}

RUN apk add --no-cache bash
COPY ./sh-scripts/startup.sh /opt/startup.sh
COPY ./sh-scripts/wait-for-it.sh /opt/wait-for-it.sh
RUN chmod +x /opt/wait-for-it.sh && chmod +x /opt/startup.sh

RUN sed -i 's/\r//g' /opt/wait-for-it.sh && sed -i 's/\r//g' /opt/startup.sh
39 changes: 39 additions & 0 deletions server/Docker/app.prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
ARG COMPOSE_PROJECT_NAME
FROM ${COMPOSE_PROJECT_NAME}-cache as cache

FROM node:18 as build
ARG WORKDIR_FLOW
WORKDIR ${WORKDIR_FLOW}

COPY --from=cache /tmp/node_modules ./node_modules
COPY . .

RUN if [ ! -f .env ]; then cp ./env-example .env; fi
RUN sed -i -e 's/^DATABASE_HOST.*/DATABASE_HOST='${COMPOSE_PROJECT_NAME}'-postgres/' -e 's/^MAIL_HOST.*/MAIL_HOST='${COMPOSE_PROJECT_NAME}'-maildev/' .env


COPY ./package*.json .
COPY ./tsconfig.build.json .

RUN yarn run build && ls dist

FROM node:18-alpine as release
MAINTAINER Pikj [Jreydman] Reyderman <[email protected]>

ARG WORKDIR_FLOW
ARG APP_PORT
WORKDIR ${WORKDIR_FLOW}

COPY --from=build ${WORKDIR_FLOW}/node_modules ./node_modules
COPY --from=build ${WORKDIR_FLOW}/.env .
COPY --from=build ${WORKDIR_FLOW}/dist ./dist
COPY --from=build ${WORKDIR_FLOW}/package*.json .

EXPOSE ${APP_PORT}

RUN apk add --no-cache bash
COPY ./sh-scripts/startup.sh /opt/startup.sh
COPY ./sh-scripts/wait-for-it.sh /opt/wait-for-it.sh
RUN chmod +x /opt/wait-for-it.sh && chmod +x /opt/startup.sh

RUN sed -i 's/\r//g' /opt/wait-for-it.sh && sed -i 's/\r//g' /opt/startup.sh
17 changes: 17 additions & 0 deletions server/Docker/cache.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:18 as build
WORKDIR /tmp
MAINTAINER Pikj [Jreydman] Reyderman <[email protected]>

COPY ["package*.json", "yarn.lock", ".yarnrc.yml", "./"]
COPY .yarn ./.yarn

RUN yarn install --immutable

FROM alpine as release
WORKDIR /tmp

COPY --from=build /tmp/node_modules ./node_modules




24 changes: 24 additions & 0 deletions server/Docker/db-prepare.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ARG COMPOSE_PROJECT_NAME
FROM ${COMPOSE_PROJECT_NAME}-cache as cache

FROM node:18-alpine as release
ARG COMPOSE_PROJECT_NAME
MAINTAINER Pikj [Jreydman] Reyderman <[email protected]>
ARG WORKDIR_FLOW
WORKDIR ${WORKDIR_FLOW}
ARG APP_PORT

COPY --from=cache /tmp/node_modules ./node_modules

COPY ["package*.json", "tsconfig*.json", ".env", "./"]

RUN sed -i -e 's/^DATABASE_HOST.*/DATABASE_HOST='${COMPOSE_PROJECT_NAME}'-postgres/' -e 's/^MAIL_HOST.*/MAIL_HOST='${COMPOSE_PROJECT_NAME}'-maildev/' .env

COPY ./src ./src

EXPOSE ${APP_PORT}

RUN apk add --no-cache bash
COPY ./sh-scripts/startup.sh /opt/startup.sh
COPY ./sh-scripts/wait-for-it.sh /opt/wait-for-it.sh
RUN chmod +x /opt/wait-for-it.sh && chmod +x /opt/startup.sh
170 changes: 170 additions & 0 deletions server/Docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
version: '3.9'

# profiles:
# - virtual-dev
# - local-dev
# - virtual-prod
# - local-prod
# - virtual-ci
# - local-ci

x-common-context: &common-context
context: ../

x-common-args: &common-args
args:
- WORKDIR_FLOW=$SERVER_PATH_CONTAINER
- APP_PORT=$APP_PORT
- COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME

x-common-config: &common-config
env_file:
- ../.env

x-common-healthcheck: &common-healthcheck
interval: 10s
timeout: 5s
retries: 5
start_period: 10s

x-common-api: &common-api
container_name: ${COMPOSE_PROJECT_NAME}-api
<<: *common-config
restart: unless-stopped
expose:
- ${APP_PORT}
ports:
- ${APP_PORT}:${APP_PORT}
depends_on:
db-prepare:
condition: service_completed_successfully
postgres:
condition: service_healthy
maildev:
condition: service_healthy


services:

postgres: #service
profiles:
- virtual-dev
- local-dev
- virtual-prod
- local-prod
- virtual-ci
- local-ci
container_name: ${COMPOSE_PROJECT_NAME}-postgres
image: postgres:16.0-alpine
<<: *common-config
expose:
- ${DATABASE_PORT}
restart: unless-stopped
environment:
POSTGRES_USER: ${DATABASE_USERNAME}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_NAME}
# <Production Activity> volumes: #production-toggle
# <Production Activity> - db-data:${DATABASE_PATH_CONTAINER}/data #production-toggle
healthcheck:
<<: *common-healthcheck
test: [ "CMD-SHELL", "pg_isready -d ${DATABASE_NAME} -U ${DATABASE_USERNAME}" ]
ports: #stage-toggle
- ${DATABASE_PORT}:${DATABASE_PORT} #stage-toggle
#endservice

maildev: #service
container_name: ${COMPOSE_PROJECT_NAME}-maildev
profiles:
- virtual-dev
- local-dev
- virtual-prod
- local-prod
- virtual-ci
- local-ci
restart: unless-stopped
build:
<<: *common-context
dockerfile: ${DOCKER_PATH_LOCAL}/maildev.Dockerfile
healthcheck:
<<: *common-healthcheck
test: [ "CMD-SHELL", "wget -O - http://localhost:${MAIL_CLIENT_PORT}/healthz || exit 1" ]
expose:
- ${MAIL_CLIENT_PORT}
- ${MAIL_PORT}
ports:
- ${MAIL_PORT}:${MAIL_PORT} #stage-toggle
- ${MAIL_CLIENT_PORT}:${MAIL_CLIENT_PORT}
#endservice

db-prepare:
profiles:
- virtual-dev
- local-dev
- virtual-prod
- local-prod
- virtual-ci
- local-ci
container_name: ${COMPOSE_PROJECT_NAME}-db-prepare
entrypoint: [ "/opt/startup.sh", "db-prepare" ]
<<: *common-config
build:
<<: [*common-context, *common-args]
dockerfile: ${DOCKER_PATH_LOCAL}/db-prepare.Dockerfile
environment:
- NODE_ENV=development
- DATABASE_HOST=${COMPOSE_PROJECT_NAME}-postgres
depends_on:
postgres:
condition: service_healthy

api-development:
profiles:
- virtual-dev
<<: *common-api
image: node:18-alpine
working_dir: ${SERVER_PATH_CONTAINER}
command: [ "yarn", "start:dev" ]
environment:
- NODE_ENV=development
- DATABASE_HOST=${COMPOSE_PROJECT_NAME}-postgres
- MAIL_HOST=${COMPOSE_PROJECT_NAME}-maildev
volumes:
- ../:${SERVER_PATH_CONTAINER}


api-production:
profiles:
- virtual-prod
<<: [*common-api, *common-config]
restart: on-failure
command: ["/opt/startup.sh", "prod"]
build:
<<: [*common-context, *common-args]
dockerfile: ${DOCKER_PATH_LOCAL}/app.prod.Dockerfile
environment:
- NODE_ENV=production
- DATABASE_HOST=${COMPOSE_PROJECT_NAME}-postgres
- MAIL_HOST=${COMPOSE_PROJECT_NAME}-maildev

api-ci:
profiles:
- virtual-ci
<<: [ *common-api, *common-config ]
restart: on-failure
command: [ "/opt/startup.sh", "ci" ]
build:
<<: [ *common-context, *common-args ]
dockerfile: ${DOCKER_PATH_LOCAL}/app.e2e.Dockerfile
environment:
- NODE_ENV=production
- DATABASE_HOST=${COMPOSE_PROJECT_NAME}-postgres
- MAIL_HOST=${COMPOSE_PROJECT_NAME}-maildev

volumes:
db-data:
driver: local
driver_opts:
type: none
o: bind
device: ../../database/data
5 changes: 5 additions & 0 deletions server/Docker/maildev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM node:18.17.1-alpine

RUN npm i -g [email protected]

CMD maildev
Loading

0 comments on commit a2f4c00

Please sign in to comment.