From 56d8a561eb38ee774f5affc1167184ee8e4a73cd Mon Sep 17 00:00:00 2001 From: Brian Nguyen Date: Thu, 25 Aug 2022 11:35:16 +0700 Subject: [PATCH] feat: readd dockerfile --- .circleci/config.yml | 6 +++- apps/reaction/.dockerignore | 16 +++++++++++ apps/reaction/Dockerfile | 14 +++++++++ apps/reaction/docker-compose.dev.yml | 25 ++++++++++++++++ apps/reaction/docker-compose.yml | 43 ++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 apps/reaction/.dockerignore create mode 100644 apps/reaction/Dockerfile create mode 100644 apps/reaction/docker-compose.dev.yml create mode 100644 apps/reaction/docker-compose.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 51fdca41611..7e5ed97e2e9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -83,7 +83,9 @@ jobs: - reaction-v6-node-modules-{{ .Branch }} - run: name: Test Unit - command: npm run test + command: | + npm run build:packages + npm run test test-integration-query: <<: *defaults @@ -108,6 +110,7 @@ jobs: command: | sudo apt-get install -y mongodb mongo --eval "rs.initiate()" + npm run build:packages npm run test:integration:query -w=apps/reaction test-integration-mutation: @@ -133,6 +136,7 @@ jobs: command: | sudo apt-get install -y mongodb mongo --eval "rs.initiate()" + npm run build:packages npm run test:integration:mutation -w=apps/reaction release: diff --git a/apps/reaction/.dockerignore b/apps/reaction/.dockerignore new file mode 100644 index 00000000000..fcb26648113 --- /dev/null +++ b/apps/reaction/.dockerignore @@ -0,0 +1,16 @@ +.build +.build.* +.npm +.git + +# This is necessary so plugins can use git repos as npm deps. +# Leave this here unless you understand the implications. +# See this issue for details: +# https://github.com/reactioncommerce/reaction/pull/5118 +!.git/modules/imports/plugins/custom + +.build.log +Dockerfile +.reaction/docker/reaction.* +docs +node_modules diff --git a/apps/reaction/Dockerfile b/apps/reaction/Dockerfile new file mode 100644 index 00000000000..6dce33985f2 --- /dev/null +++ b/apps/reaction/Dockerfile @@ -0,0 +1,14 @@ +# Dockerfile for production builds +FROM reactioncommerce/node-prod:14.18.1-v1 + +ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/src/app/node_modules/.bin + +# The `node-prod` base image installs NPM deps with --no-scripts. +# This prevents the `sharp` lib from working because it installs the binaries +# in a post-install script. We copy their install script here and run it. +# hadolint ignore=DL3003,SC2015 +RUN cd node_modules/sharp && (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy) + +# The base image copies /src but we need to copy additional folders in this project +COPY --chown=node:node ./public ./public +COPY --chown=node:node ./plugins.json ./plugins.json diff --git a/apps/reaction/docker-compose.dev.yml b/apps/reaction/docker-compose.dev.yml new file mode 100644 index 00000000000..d0fc227b0b3 --- /dev/null +++ b/apps/reaction/docker-compose.dev.yml @@ -0,0 +1,25 @@ +# This docker-compose file is used to run the project in Docker for development. +# The local files are mounted into the created container. +# +# Usage: +# ln -s docker-compose.dev.yml docker-compose.override.yml +# docker-compose up [-d] +# +# To go back to running the published image: +# rm docker-compose.override.yml + +version: '3.4' + +services: + api: + image: reactioncommerce/node-dev:14.18.1-v1 + ports: + - "3000:3000" + - "9229:9229" + volumes: + - .:/usr/local/src/app:cached + - api_node_modules:/usr/local/src/app/node_modules # do not link node_modules in, and persist it between dc up runs + +volumes: + mongo-db4: + api_node_modules: diff --git a/apps/reaction/docker-compose.yml b/apps/reaction/docker-compose.yml new file mode 100644 index 00000000000..8815826cb10 --- /dev/null +++ b/apps/reaction/docker-compose.yml @@ -0,0 +1,43 @@ +# This docker-compose file is used to run the project's published image +# +# Usage: docker-compose up [-d] +# +# See comment in docker-compose.dev.yml if you want to run for development. + +version: "3.4" + +networks: + reaction: + external: + name: reaction.localhost + +services: + api: + image: reactioncommerce/reaction:4.2.0 + depends_on: + - mongo + env_file: + - ./.env + networks: + default: + reaction: + ports: + - "3000:3000" + + mongo: + image: mongo:4.2.0 + command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger + networks: + default: + reaction: + ports: + - "27017:27017" + volumes: + - mongo-db4:/data/db + healthcheck: # re-run rs.initiate() after startup if it failed. + test: test $$(echo "rs.status().ok || rs.initiate().ok" | mongo --quiet) -eq 1 + interval: 10s + start_period: 30s + +volumes: + mongo-db4: