-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from panoratech/docker-compose-monorepo-upgrade
feat: Fully Dockerized Monorepo Turbo
- Loading branch information
Showing
6 changed files
with
11,725 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pg_data/ | ||
node_modules/ | ||
|
||
apps/webapp/node_modules | ||
apps/webapp/dist | ||
|
||
packages/api/node_modules | ||
packages/api/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,48 @@ | ||
# build stage | ||
FROM node:20-alpine as build-stage | ||
# run directly from the repo root directory | ||
# docker build -f ./apps/webapp/Dockerfile . | ||
FROM node:20-alpine AS base | ||
# ======================================================================= | ||
FROM base AS builder | ||
RUN apk add --no-cache libc6-compat | ||
RUN apk update | ||
|
||
# Set pnpm | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
WORKDIR /app | ||
COPY package*.json ./ | ||
RUN npm install | ||
RUN pnpm add -g turbo | ||
COPY . . | ||
RUN npm run build | ||
RUN turbo prune webapp --docker | ||
RUN ls -la ./out/full/apps/webapp | ||
|
||
# ======================================================================= | ||
# Add lockfile and package.json's of isolated subworkspace | ||
FROM base AS installer | ||
RUN apk add --no-cache libc6-compat | ||
RUN apk update | ||
# Set pnpm | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
WORKDIR /app | ||
|
||
# First install the dependencies (as they change less often) | ||
COPY .gitignore .gitignore | ||
COPY --from=builder /app/out/json/ . | ||
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml | ||
RUN pnpm install | ||
|
||
# Build the project | ||
COPY --from=builder ./app/out/full/ . | ||
RUN pnpm turbo run build --filter=webapp... | ||
|
||
# ======================================================================== | ||
FROM nginx:stable-alpine as runner | ||
|
||
# production stage | ||
FROM nginx:stable-alpine as production-stage | ||
COPY --from=build-stage /app/dist/ /usr/share/nginx/html | ||
RUN ls -la /usr/share/nginx/html | ||
RUN ls -la /usr/share/nginx/html | ||
COPY --from=installer ./app/apps/webapp/dist/ /usr/share/nginx/html | ||
|
||
EXPOSE 80 | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.