-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (39 loc) · 1.38 KB
/
Copy pathDockerfile
File metadata and controls
44 lines (39 loc) · 1.38 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
ARG ALPINE_VERSION=3.24.1
ARG BUN_VERSION=1.3.14
ARG NGINX_VERSION=1.31.2
### STAGE 1: Build nginx + brotli ###
FROM alpine:${ALPINE_VERSION} AS brotli-stage
ARG NGINX_VERSION
RUN apk add --no-cache \
build-base \
pcre-dev \
zlib-dev \
openssl-dev \
wget \
git \
brotli-dev
WORKDIR /app
RUN wget "https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" \
&& tar -zxf "nginx-${NGINX_VERSION}.tar.gz" \
&& ln -s "nginx-${NGINX_VERSION}" nginx \
&& git clone --recurse-submodules -j8 https://github.com/google/ngx_brotli \
&& cd nginx \
&& ./configure --with-compat --add-dynamic-module=../ngx_brotli \
&& make modules
### STAGE 2: Build frontend ###
FROM oven/bun:${BUN_VERSION}-alpine AS build-stage
WORKDIR /bybe
COPY . .
ARG API_URL
ENV API_URL=$API_URL
RUN bun install --ignore-scripts && bun run build
### STAGE 3: Deploy ###
FROM nginxinc/nginx-unprivileged:${NGINX_VERSION}-alpine AS deploy-stage
COPY --from=brotli-stage /app/nginx/objs/ngx_http_brotli_static_module.so /etc/nginx/modules/
COPY --from=brotli-stage /app/nginx/objs/ngx_http_brotli_filter_module.so /etc/nginx/modules/
COPY --from=build-stage /bybe/nginx.conf /etc/nginx/nginx.conf
COPY --from=build-stage /bybe/nginx_headers.conf /etc/nginx/nginx_headers.conf
COPY --from=build-stage /bybe/dist/spa /usr/share/nginx/html
EXPOSE 8080
USER nginx
CMD ["nginx", "-g", "daemon off;"]