Skip to content

Commit

Permalink
chore: reduce docker layers
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1230 committed May 16, 2024
1 parent 90cb119 commit ea56265
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ node_modules/
.github/
.vscode/
docs/
docker/**/*.yml

secrets/
.env
Expand Down
24 changes: 12 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM node:21-alpine AS base
RUN corepack enable
RUN apk add --no-cache bash libc6-compat
RUN apk update && yarn global add turbo
RUN corepack enable \
&& apk add --no-cache bash libc6-compat \
&& apk update && yarn global add turbo
WORKDIR /web
ENV TURBO_TELEMETRY_DISABLED=1

Expand All @@ -14,12 +14,11 @@ COPY apps apps
COPY packages packages
COPY tooling tooling

# Remove all files except package.json
RUN find apps -type f ! -name 'package.json' -delete
RUN find packages -type f ! -name 'package.json' -delete
RUN find tooling -type f ! -name 'package.json' -delete

RUN yarn install
# Remove all files except package.json to optimize cache usage
RUN find apps -type f ! -name 'package.json' -delete \
&& find packages -type f ! -name 'package.json' -delete \
&& find tooling -type f ! -name 'package.json' -delete \
&& yarn install

## Builder
FROM dependencies AS builder
Expand All @@ -43,9 +42,10 @@ WORKDIR /web/
ENV NODE_ENV=production
ENV CLIENT_BUILD_DIR=web

# install node
RUN apt-get update && apt-get install -y curl
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | /bin/bash - && apt-get install -y nodejs
# Install node
RUN apt-get update && apt-get install -y curl \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs

COPY docker/entrypoint.sh /web/entrypoint.sh
COPY --from=builder /web/ .
Expand Down

0 comments on commit ea56265

Please sign in to comment.