-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (46 loc) · 1.55 KB
/
Dockerfile
File metadata and controls
64 lines (46 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# ------------------
# Stage 1: Build
# ------------------
FROM node:22-bookworm-slim AS builder
WORKDIR /app
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
# Copy dependency files first for layer caching
COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn .yarn
RUN corepack enable && yarn install --immutable
# Copy source code (invalidates cache on code changes only)
COPY . .
# Build, prune dev deps, clean up
RUN yarn build \
&& yarn workspaces focus --all --production \
&& rm -rf .yarn/
# ------------------
# Stage 2: Production
# ------------------
FROM node:22-bookworm-slim
ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=America/Los_Angeles
ARG VERSION=dev
ENV VERSION=$VERSION
ENV TZ=$TZ
ENV NODE_ENV=production
ENV IN_DOCKER=true
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
# OCI labels
LABEL org.opencontainers.image.source=https://github.com/algolia/renderscript
LABEL org.opencontainers.image.revision=$VERSION
WORKDIR /app/renderscript
COPY --from=builder --chown=node:node /app/package.json ./
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
RUN apt-get update \
&& apt-get install -y --no-install-recommends tzdata \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& npx playwright install --with-deps chromium firefox \
&& chown -R node:node /ms-playwright \
&& rm -rf /var/lib/apt/lists/*
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
COPY --from=builder --chown=node:node /app/dist ./dist
COPY --from=builder --chown=node:node /app/public ./public
USER node
CMD [ "node", "dist/index.js" ]