From f286b6aa285e147643dc88c0c65f1a87d6c80acc Mon Sep 17 00:00:00 2001 From: MedadRufus Date: Tue, 26 Oct 2021 18:21:04 +0100 Subject: [PATCH 1/8] put in docker support --- .dockerignore | 7 +++++++ Dockerfile | 24 ++++++++++++++++++++++++ docker-compose.yml | 7 +++++++ 3 files changed, 38 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3eff0a4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +* + +!yarn-offline-mirror/ +!src/ +!package.json +!yarn.lock +!.yarnrc diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5019f8b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# This stage installs our modules +FROM mhart/alpine-node:12 +WORKDIR /app + +# If you have native dependencies, you'll need extra tools +# RUN apk add --no-cache make gcc g++ python3 + +# RUN npm ci --prod + +# Then we copy over the modules from above onto a `slim` image +FROM mhart/alpine-node:slim-12 + +# If possible, run your container using `docker run --init` +# Otherwise, you can use `tini`: +# RUN apk add --no-cache tini +# ENTRYPOINT ["/sbin/tini", "--"] + +WORKDIR /app +COPY --from=0 /app . +COPY . . +RUN yarn + + +CMD yarn start diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..45446b8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: '3.8' + +services: + web: + build: . + ports: + - "3200:3200" From e3d1198a08784b8e7de433a1df9eb92ddc95df77 Mon Sep 17 00:00:00 2001 From: MedadRufus Date: Tue, 26 Oct 2021 18:27:48 +0100 Subject: [PATCH 2/8] nearly works --- Dockerfile | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5019f8b..7664e8a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,11 @@ -# This stage installs our modules -FROM mhart/alpine-node:12 -WORKDIR /app +FROM node:14-alpine -# If you have native dependencies, you'll need extra tools -# RUN apk add --no-cache make gcc g++ python3 +COPY package.json . +COPY yarn.lock . +RUN yarn install -# RUN npm ci --prod +COPY public/ ./public/ +COPY src/ ./src/ -# Then we copy over the modules from above onto a `slim` image -FROM mhart/alpine-node:slim-12 - -# If possible, run your container using `docker run --init` -# Otherwise, you can use `tini`: -# RUN apk add --no-cache tini -# ENTRYPOINT ["/sbin/tini", "--"] - -WORKDIR /app -COPY --from=0 /app . -COPY . . -RUN yarn - - -CMD yarn start +EXPOSE 3200 +CMD yarn run start \ No newline at end of file From 71b5404d13c3d75b5cf14b2c41fa0dad3223f9d2 Mon Sep 17 00:00:00 2001 From: MedadRufus Date: Tue, 26 Oct 2021 18:48:58 +0100 Subject: [PATCH 3/8] working --- .dockerignore | 4 ++++ Dockerfile | 10 +++++++--- docker-compose.yml | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3eff0a4..ff378ef 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,11 @@ * +!craco.config.js +!tailwind.config.js +!tsconfig.json !yarn-offline-mirror/ !src/ +!public/ !package.json !yarn.lock !.yarnrc diff --git a/Dockerfile b/Dockerfile index 7664e8a..3ef60b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14-alpine +FROM node:14 COPY package.json . COPY yarn.lock . @@ -6,6 +6,10 @@ RUN yarn install COPY public/ ./public/ COPY src/ ./src/ +COPY yarn.lock . +COPY craco.config.js . +COPY tailwind.config.js . +COPY tsconfig.json . -EXPOSE 3200 -CMD yarn run start \ No newline at end of file +EXPOSE 3000 +CMD yarn start \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 45446b8..23173e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,4 +4,4 @@ services: web: build: . ports: - - "3200:3200" + - "3000:3000" From 55e71da997116106e3b06dc7da7a4d5205db3352 Mon Sep 17 00:00:00 2001 From: MedadRufus Date: Tue, 26 Oct 2021 19:03:40 +0100 Subject: [PATCH 4/8] simplify --- Dockerfile | 19 +++++++++++-------- docker-compose.yml | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3ef60b7..da67f1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,6 @@ -FROM node:14 - -COPY package.json . -COPY yarn.lock . -RUN yarn install - +FROM node:14 as build-deps +WORKDIR /usr/src/app +COPY package.json yarn.lock ./ COPY public/ ./public/ COPY src/ ./src/ COPY yarn.lock . @@ -11,5 +8,11 @@ COPY craco.config.js . COPY tailwind.config.js . COPY tsconfig.json . -EXPOSE 3000 -CMD yarn start \ No newline at end of file +RUN yarn +COPY . ./ +RUN yarn build + +FROM nginx:1.12-alpine +COPY --from=build-deps /usr/src/app/build /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 23173e5..61d0297 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,4 +4,4 @@ services: web: build: . ports: - - "3000:3000" + - "80:80" From 1308ad98ba29c0fa1c85d6c79b39a8018c140047 Mon Sep 17 00:00:00 2001 From: MedadRufus Date: Tue, 26 Oct 2021 19:36:19 +0100 Subject: [PATCH 5/8] works with alon --- Dockerfile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index da67f1b..362e0aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,13 @@ FROM node:14 as build-deps WORKDIR /usr/src/app COPY package.json yarn.lock ./ -COPY public/ ./public/ -COPY src/ ./src/ -COPY yarn.lock . -COPY craco.config.js . -COPY tailwind.config.js . -COPY tsconfig.json . RUN yarn COPY . ./ RUN yarn build FROM nginx:1.12-alpine -COPY --from=build-deps /usr/src/app/build /usr/share/nginx/html +COPY --from=build-deps /usr/src/app/build /usr/share/nginx/html/alon + EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file From b27930e7bea1634d502f4771beb784e727954dd9 Mon Sep 17 00:00:00 2001 From: MedadRufus Date: Tue, 26 Oct 2021 20:31:23 +0100 Subject: [PATCH 6/8] update readme to deploy with docker --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index e5597b8..f86d347 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,22 @@ Deploy Alon on Github Pages: $ yarn deploy ``` +## Deploy on docker + +Fire it up, building from your local respository with: +```bash +docker-compose up +``` + +Otherwise, you can run a pre built image from dockerhub. Pull and run from dockerhub with the following command: + +```bash +$ docker run --name alon -p 80:80 medadnewman/alon_web:latest +``` + +It should pull the latest image and will be viewable at the `/alon` subpage(e.g. `localhost/alon`) + + ## roadmap - Better code/file navigation From d9834897c2b8878530e13b119e58a70ca2214c45 Mon Sep 17 00:00:00 2001 From: MedadRufus Date: Tue, 26 Oct 2021 20:32:19 +0100 Subject: [PATCH 7/8] fix file ending --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 362e0aa..713a892 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,4 +10,4 @@ FROM nginx:1.12-alpine COPY --from=build-deps /usr/src/app/build /usr/share/nginx/html/alon EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] From 4c1859c62b82875a72ee315d9c4c598e5cdc223e Mon Sep 17 00:00:00 2001 From: MedadRufus Date: Tue, 26 Oct 2021 20:34:35 +0100 Subject: [PATCH 8/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f86d347..b1b2695 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,10 @@ docker-compose up Otherwise, you can run a pre built image from dockerhub. Pull and run from dockerhub with the following command: ```bash -$ docker run --name alon -p 80:80 medadnewman/alon_web:latest +$ docker run -d --name alon -p 80:80 medadnewman/alon_web:latest ``` -It should pull the latest image and will be viewable at the `/alon` subpage(e.g. `localhost/alon`) +It should pull the latest image and will be viewable at the `/alon` subpage(e.g. `http://localhost/alon/`) ## roadmap