From 881398f64095d1a2aed4f58511e55e339668ab3b Mon Sep 17 00:00:00 2001 From: nchitrak Date: Thu, 1 Jun 2023 13:08:03 +0200 Subject: [PATCH 1/3] added docker for vue --- docker-compose.yml | 23 +++++++++++++++++++++++ docker/Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 docker-compose.yml create mode 100644 docker/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..484e087 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: "3" + +services: + web: + container_name: web + build: + args: + APP_SCOPE : "web" + context: . + dockerfile: ./docker/Dockerfile + restart: always + ports: + - "3000:80" + docs: + container_name: docs + build: + args: + APP_SCOPE: "docs" + context: . + dockerfile: ./docker/Dockerfile + restart: always + ports: + - "3001:80" diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..b1143ae --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,37 @@ +FROM node:18-alpine AS base + +FROM base AS builder +ARG APP_SCOPE +ENV APP_SCOPE ${APP_SCOPE} +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +RUN apk update +WORKDIR /app +RUN yarn global add turbo +COPY . . +RUN yarn turbo prune --scope=${APP_SCOPE} --docker + +# Add lockfile and package.json's of isolated subworkspace +FROM base AS installer +ARG APP_SCOPE +ENV APP_SCOPE ${APP_SCOPE} +RUN apk add --no-cache libc6-compat +RUN apk update +WORKDIR /app +COPY .gitignore .gitignore +COPY --from=builder /app/out/json/ . +COPY --from=builder /app/out/yarn.lock ./yarn.lock +COPY --from=builder /app/out/full/ . +RUN yarn install +COPY turbo.json turbo.json +RUN yarn turbo run build --scope=${APP_SCOPE} + +# production stage +FROM nginx:stable-alpine as production-stage +ARG APP_SCOPE +ENV APP_SCOPE ${APP_SCOPE} +COPY --from=installer /app/apps/${APP_SCOPE}/dist /usr/share/nginx/html +EXPOSE 80 +STOPSIGNAL SIGTERM +CMD ["nginx", "-g", "daemon off;"] + From 0ede7f326d1dcdc40f1848cfbfda7c4b87a768e4 Mon Sep 17 00:00:00 2001 From: nchitrak Date: Thu, 1 Jun 2023 13:21:29 +0200 Subject: [PATCH 2/3] added readme for docker usage --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index ee207ec..91cc731 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,44 @@ Learn more about the power of Turborepo: - [Scoped Tasks](https://turborepo.org/docs/features/scopes) - [Configuration Options](https://turborepo.org/docs/reference/configuration) - [CLI Usage](https://turborepo.org/docs/reference/command-line-reference) + +### Docker Support + +If you want to deploy with docker there is a Dockerfile included to help with that +_Note: Dockerfile only works to build docker image to deploy and does not support local development_ + +#### How to build +Run this command to build a docker image where the {SCOPE_NAME} is the workspace you want to build +```go +docker-compose up {SCOPE_NAME} +``` + +For example: +```go +docker-compose up web +``` +Brings up web app and +```go +docker-compose up docs +``` +Brings up docs app + +if you want to add another app and build a docker image for it, you can just add a new service in docker-compose like +```yaml + newapp: + container_name: newapp + build: + args: + APP_SCOPE: "newapp" + context: . + dockerfile: ./docker/Dockerfile + restart: always + ports: + - "3003:80" +``` + +and run +```go +docker-compose up newapp +``` +to bring up newapp app \ No newline at end of file From ca6a0dfef50eb88aab600befb7c1523642bedfe8 Mon Sep 17 00:00:00 2001 From: nchitrak Date: Thu, 1 Jun 2023 13:22:35 +0200 Subject: [PATCH 3/3] added readme for docker usage --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 91cc731..9d6880c 100644 --- a/README.md +++ b/README.md @@ -68,16 +68,16 @@ _Note: Dockerfile only works to build docker image to deploy and does not suppor #### How to build Run this command to build a docker image where the {SCOPE_NAME} is the workspace you want to build -```go +```shell docker-compose up {SCOPE_NAME} ``` For example: -```go +```shell docker-compose up web ``` Brings up web app and -```go +```shell docker-compose up docs ``` Brings up docs app @@ -97,7 +97,7 @@ if you want to add another app and build a docker image for it, you can just add ``` and run -```go +```shell docker-compose up newapp ``` to bring up newapp app \ No newline at end of file