From a687e1e1e3b3abd86f9fdb32a4a8657837af12fc Mon Sep 17 00:00:00 2001 From: chenos Date: Mon, 14 Dec 2020 17:06:05 +0800 Subject: [PATCH] chore: add app container --- .dockerignore | 3 +++ Dockerfile | 19 +++++++++++++++++++ docker-compose.yml | 16 +++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..3afb46f5e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +.env +packages/app/.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..b1a9548b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:12.20.0-stretch + +WORKDIR /app +COPY . /app +RUN ls -a + +RUN npm config set registry https://registry.npm.taobao.org +RUN npm install +RUN npm run bootstrap +RUN npm run build + +# # Install app dependencies +# ENV NPM_CONFIG_LOGLEVEL warn +# RUN yarn install + +# # Show current folder structure in logs +RUN ls -a + +# CMD [ "npm", "run", "serve" ] diff --git a/docker-compose.yml b/docker-compose.yml index 745268718..4b3e8adab 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,13 +27,27 @@ services: restart: always ports: - "${DB_MYSQL_PORT}:3306" + networks: + - node-network postgres: image: postgres:10 restart: always ports: - "${DB_POSTGRES_PORT}:5432" + networks: + - node-network command: postgres -c wal_level=logical environment: POSTGRES_USER: ${DB_USER} POSTGRES_DB: ${DB_DATABASE} - POSTGRES_PASSWORD: ${DB_PASSWORD} \ No newline at end of file + POSTGRES_PASSWORD: ${DB_PASSWORD} + app: + build: + context: . + dockerfile: Dockerfile + command: [ "yarn", "start" ] + ports: + - "${APP_HTTP_PORT}:${APP_HTTP_PORT}" + - "${HTTP_PORT}:${HTTP_PORT}" + networks: + - node-network \ No newline at end of file