-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
25 lines (22 loc) · 927 Bytes
/
Dockerfile
File metadata and controls
25 lines (22 loc) · 927 Bytes
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
FROM oven/bun:latest AS base
WORKDIR /usr/src/app
# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/prod
COPY package.json bun.lock /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production
# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/prod/node_modules node_modules
COPY . .
# build
RUN bun --bun run generate
# compress
RUN apt update
RUN apt install brotli
RUN find .output/public/ \( -iname '*.html' -o -iname '*.css' -o -iname '*.js' \) -exec bash -c 'brotli --best "$0"' {} \;
RUN find .output/public/ \( -iname '*.html' -o -iname '*.css' -o -iname '*.js' \) -exec bash -c 'gzip -k --best "$0"' {} \;
FROM tinawng/nginx-static-compressed:latest AS release
COPY --from=prerelease /usr/src/app/.output/public /static