From dea917bea41cebeaea10017d996e8a17134e3db1 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Mon, 20 May 2019 21:25:44 -0400 Subject: [PATCH 1/5] Fix cpx command on linux? --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 52f35e252..57e7ce1cf 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "orthanc:up": "docker-compose -f docker/Nginx-Orthanc/docker-compose.yml up", "dev:orthanc": "yarn run preBuild && cross-env PORT=5000 REACT_APP_CONFIG=config/docker_nginx-orthanc.js react-scripts start", "version": "node -p -e \"'export default \\'' + require('./package.json').version + '\\';'\" > src/version.js", - "copy:webworkers": "cpx 'node_modules/cornerstone-wado-image-loader/dist/*.min.js*' public" + "copy:webworkers": "cpx \"node_modules/cornerstone-wado-image-loader/dist/*.min.js*\" \"public\" -v" }, "husky": { "hooks": { From c9630c6a8b59cb7131b1b854b0965250affc3b42 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Mon, 20 May 2019 21:26:18 -0400 Subject: [PATCH 2/5] Rename dockerfile-web --> dockerfile --- dockerfile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ dockerfile-web | 25 ------------------------- 2 files changed, 48 insertions(+), 25 deletions(-) create mode 100644 dockerfile delete mode 100644 dockerfile-web diff --git a/dockerfile b/dockerfile new file mode 100644 index 000000000..1421bcbbf --- /dev/null +++ b/dockerfile @@ -0,0 +1,48 @@ +# This dockerfile is used to publish the `ohif/viewer` image on dockerhub. +# +# It's a good example of how to build our static application and package it +# with a web server capable of hosting it as static content. +# +# docker build +# -------------- +# If you would like to use this dockerfile to build and tag an image, make sure +# you set the context to the project's root directory: +# https://docs.docker.com/engine/reference/commandline/build/ +# +# +# SUMMARY +# -------------- +# This dockerfile has two stages: +# +# 1. Building the React application for production +# 2. Setting up our Nginx (Alpine Linux) image w/ step one's output +# + + +# Stage 1: Build the application +# docker build -t ohif/viewer:latest . +FROM node:11.2.0-slim as builder + +# RUN apt-get update && apt-get install -y git yarn +RUN mkdir /usr/src/app +WORKDIR /usr/src/app + +ENV PATH /usr/src/app/node_modules/.bin:$PATH +ENV GENERATE_SOURCEMAP=false + +COPY package.json /usr/src/app/package.json +COPY yarn.lock /usr/src/app/yarn.lock + +ADD . /usr/src/app/ +RUN yarn install +RUN yarn run build:web + +# Stage 2: Bundle the built application into a Docker container +# which runs Nginx using Alpine Linux +FROM nginx:1.15.5-alpine +RUN rm -rf /etc/nginx/conf.d +COPY docker/Viewer-v2.x /etc/nginx/conf.d +COPY --from=builder /usr/src/app/build /usr/share/nginx/html +EXPOSE 80 +EXPOSE 443 +CMD ["nginx", "-g", "daemon off;"] diff --git a/dockerfile-web b/dockerfile-web deleted file mode 100644 index 23c027cfe..000000000 --- a/dockerfile-web +++ /dev/null @@ -1,25 +0,0 @@ -# Stage 1: Build the application -# docker build -t ohif/viewer:latest . -FROM node:11.2.0-slim as builder - -# RUN apt-get update && apt-get install -y git yarn -RUN mkdir /usr/src/app -WORKDIR /usr/src/app - -ENV PATH /usr/src/app/node_modules/.bin:$PATH - -COPY package.json /usr/src/app/package.json -COPY yarn.lock /usr/src/app/yarn.lock - -ADD . /usr/src/app/ -RUN yarn install -RUN yarn run build:web - -# # Stage 2: Bundle the built application into a Docker container -# # which runs Nginx using Alpine Linux -FROM nginx:1.15.5-alpine -RUN rm -rf /etc/nginx/conf.d -COPY conf /etc/nginx -COPY --from=builder /usr/src/app/build /usr/share/nginx/html -EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] From 851ec0be6ad36de9d78009eaa1b552613f973344 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Mon, 20 May 2019 21:26:39 -0400 Subject: [PATCH 3/5] Add a docker_publish job --- .circleci/config.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 14d013f70..2dc8a290b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -72,6 +72,20 @@ jobs: name: Publish using Semantic Release command: npx semantic-release --debug --dry-run + docker_publish: + <<: *defaults + steps: + - attach_workspace: + at: ~/repo + - setup_remote_docker: + docker_layer_caching: true + - run: + name: Build and push Docker image + command: | + docker build -t ohif/$IMAGE_NAME:$TAG . + echo $DOCKER_PWD | docker login -u $DOCKER_LOGIN --password-stdin + docker push ohif/$IMAGE_NAME:$TAG + docs_publish: <<: *defaults steps: From 5e81fe8336729087f8a463f34ae2d9b87be3e012 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Mon, 20 May 2019 21:27:04 -0400 Subject: [PATCH 4/5] Add a default nginx config to use for our published image --- docker/Viewer-v2.x/default.conf | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 docker/Viewer-v2.x/default.conf diff --git a/docker/Viewer-v2.x/default.conf b/docker/Viewer-v2.x/default.conf new file mode 100644 index 000000000..93cba3df8 --- /dev/null +++ b/docker/Viewer-v2.x/default.conf @@ -0,0 +1,12 @@ +server { + listen 80; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} From d9e9fc45a100777dfde5b01357e6e39ce6206bc9 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Mon, 20 May 2019 21:27:47 -0400 Subject: [PATCH 5/5] Add docker_publish to master merge --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2dc8a290b..6ed720844 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -133,3 +133,6 @@ workflows: - docs_publish: requires: - build_and_test + - docker_publish: + requires: + - build_and_test