From 140c061953eac6ddc96ead391eea79eec74f92c6 Mon Sep 17 00:00:00 2001 From: BeatLink Date: Thu, 3 Dec 2020 22:23:52 -0500 Subject: [PATCH 1/3] Add Docker Build --- docker/Dockerfile | 17 +++++++++++++++++ docker/nginx.conf | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/nginx.conf diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..0919ea6 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,17 @@ +# Builds the Web Client from the latest git repo + +# Build Stage ===================================================================================== +FROM node:alpine as build +ENV DEFAULT_ETEBASE_SERVER "http://example.com" +RUN export REACT_APP_DEFAULT_API_PATH=${DEFAULT_ETEBASE_SERVER} && \ + git clone https://github.com/etesync/etesync-web.git etesync-web && \ + cd etesync-web && \ + yarn && \ + yarn build + +# Run Stage ======================================================================================= +FROM nginx:alpine +COPY --from=build /etesync-web/build /usr/share/nginx/html +COPY ./nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +EOF diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..a4a72a8 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,17 @@ +server { + + listen 80 default_server; + listen [::]:80 default_server; + charset utf-8; + client_max_body_size 75M; # max upload size + location / { + root /usr/share/nginx/html; + try_files $uri $uri/ /index.html =404; + autoindex on; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} +EOF From b99c8110ce1bcab162d4308d3efc0ab69c8735b3 Mon Sep 17 00:00:00 2001 From: BeatLink Date: Thu, 3 Dec 2020 22:39:13 -0500 Subject: [PATCH 2/3] Add comments, remove erroneous lines, simplify env variable --- docker/Dockerfile | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 0919ea6..bdee1a5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,17 +1,34 @@ # Builds the Web Client from the latest git repo +# Two stages are used to reduce complexity and final image size. The first stage builds the actual +# client. The second stage runs the web client using an nginx server, using the nginx +# configurations in this folder as well as the built files from the previous stage. + # Build Stage ===================================================================================== + +# Use node image for build step (this has yarn which we need) FROM node:alpine as build -ENV DEFAULT_ETEBASE_SERVER "http://example.com" -RUN export REACT_APP_DEFAULT_API_PATH=${DEFAULT_ETEBASE_SERVER} && \ - git clone https://github.com/etesync/etesync-web.git etesync-web && \ + +# This variable allows you to set the default etesync server for the web client. +# Change this to your own server if self hosting. +ENV REACT_APP_DEFAULT_API_PATH "https://api.etebase.com/partner/etesync/" + +# Clones the latest web client code from git and builds the client and its dependencies with yarn +RUN git clone https://github.com/etesync/etesync-web.git etesync-web && \ cd etesync-web && \ yarn && \ yarn build # Run Stage ======================================================================================= + +# This lightweight image contains nginx which will run the web client FROM nginx:alpine + +# Grabs the built web client files from the previous build stage COPY --from=build /etesync-web/build /usr/share/nginx/html + +# Copies the nginx configuration from this folder to the running container COPY ./nginx.conf /etc/nginx/conf.d/default.conf + +# Exposes port 80, the port nginx is configured to listen on EXPOSE 80 -EOF From 267f05e0402faeb0c0a2bb98bb9663d785f3c02e Mon Sep 17 00:00:00 2001 From: BeatLink Date: Thu, 3 Dec 2020 23:30:25 -0500 Subject: [PATCH 3/3] Add command to install git --- docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index bdee1a5..847c9f2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,7 +14,8 @@ FROM node:alpine as build ENV REACT_APP_DEFAULT_API_PATH "https://api.etebase.com/partner/etesync/" # Clones the latest web client code from git and builds the client and its dependencies with yarn -RUN git clone https://github.com/etesync/etesync-web.git etesync-web && \ +RUN apk add --no-cache git && \ + git clone https://github.com/etesync/etesync-web.git etesync-web && \ cd etesync-web && \ yarn && \ yarn build