Skip to content

Commit 724a13e

Browse files
committed
Slashed docker image size by 170mb
1 parent 8dd0aad commit 724a13e

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Dockerfile

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ FROM python:3.11-alpine3.20 AS base
22

33
FROM base AS deps
44

5+
# Prevent __pycache__ directories
6+
ENV PYTHONUNBUFFERED=1 \
7+
PYTHONDONTWRITEBYTECODE=1
8+
9+
510
RUN addgroup -g 1000 beetle && \
611
adduser -D -u 1000 -G beetle beetle
712

@@ -26,26 +31,17 @@ RUN --mount=type=cache,target=/var/cache/apk \
2631
apk add \
2732
imagemagick \
2833
redis \
29-
git \
3034
bash \
31-
keyfinder-cli \
3235
tmux \
33-
wget \
34-
npm \
3536
shadow
3637

37-
# pnpm
38-
RUN npm install -g pnpm
39-
4038
# Install our package (backend)
4139
COPY ./backend /repo/backend
4240
COPY ./README.md /repo/README.md
4341
WORKDIR /repo/backend
4442
RUN --mount=type=cache,target=/root/.cache/pip \
45-
pip install .
43+
pip install --no-cache-dir .
4644

47-
# Frontend
48-
RUN pnpm config set store-dir /repo/frontend/.pnpm-store
4945

5046
# ------------------------------------------------------------------------------------ #
5147
# Development #
@@ -78,8 +74,14 @@ ENTRYPOINT ["./entrypoint_test.sh"]
7874
# ------------------------------------------------------------------------------------ #
7975

8076
FROM deps AS build
77+
# Build frontend files
8178

82-
COPY --from=deps /repo /repo
79+
RUN --mount=type=cache,target=/var/cache/apk \
80+
apk add \
81+
npm
82+
83+
RUN npm install -g pnpm
84+
RUN pnpm config set store-dir /repo/frontend/.pnpm-store
8385

8486
WORKDIR /repo
8587
COPY ./frontend ./frontend/
@@ -98,7 +100,6 @@ FROM deps AS prod
98100
ENV IB_SERVER_CONFIG="prod"
99101

100102
WORKDIR /repo
101-
COPY --from=deps /repo /repo
102103
COPY --from=build /repo/frontend/dist /repo/frontend/dist
103104
COPY entrypoint.sh .
104105
COPY entrypoint_fix_permissions.sh .
@@ -114,3 +115,4 @@ ENTRYPOINT [ \
114115
su beetle -c /repo/entrypoint.sh" \
115116
]
116117

118+

0 commit comments

Comments
 (0)