From fd82d4270e34d27f88fce03f00ad336b4fa10e6f Mon Sep 17 00:00:00 2001 From: Babak Date: Mon, 12 Mar 2018 14:24:07 +0330 Subject: [PATCH] Initial commit for dockerizing frontend --- .dockerignore | 1 + Dockerfile | 21 +++++++++++++++++++++ docker-compose.yml | 16 ++++++++++++++++ run.sh | 19 +++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 run.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8cf4686 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM node:8 + +ADD yarn.lock /yarn.lock +ADD package.json /package.json + +ENV NODE_PATH=/node_modules +ENV PATH=$PATH:/node_modules/.bin + +COPY package.json /usr/src/app/package.json + +WORKDIR /app +ADD . /app +COPY package.json app/package.json + +RUN yarn install + +EXPOSE 3000 +EXPOSE 35729 + +ENTRYPOINT ["/bin/bash", "/app/run.sh"] +CMD ["start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..af6735f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3.0' + +services: + + forkdelta-frontend: + container_name: forkdelta-frontend + build: + context: . + dockerfile: Dockerfile + volumes: + - '.:/usr/src/app' + - '/usr/src/app/node_modules' + ports: + - '3000:3000' + environment: + - NODE_ENV=production \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..fccb1ec --- /dev/null +++ b/run.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -eo pipefail + +case $1 in + start) + # The '| cat' is to trick Node that this is an non-TTY terminal + # then react-scripts won't clear the console. + yarn start | cat + ;; + build) + yarn build + ;; + test) + yarn test $@ + ;; + *) + exec "$@" + ;; +esac \ No newline at end of file