-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
78 lines (69 loc) · 1.89 KB
/
Dockerfile
File metadata and controls
78 lines (69 loc) · 1.89 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# syntax=docker/dockerfile:1.4
ARG NODE_VERSION=23.7.0
ARG NGINX_VERSION=1.23.3
# Development
FROM node:${NODE_VERSION}-bullseye as dev
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apt-get update && \
apt-get upgrade -yqq && \
npm update --global npm && \
corepack enable
#
# Builder
#
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION}-bullseye as builder
ARG GITHUB_REF_NAME=""
ARG GITHUB_SHA=""
ENV GITHUB_REF_NAME=${GITHUB_REF_NAME}
ENV GITHUB_SHA=${GITHUB_SHA}
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
# RUN apk update && apk upgrade && npm update -g npm
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/pnpm/store,id=harrybrwn.github.io-npm-cache \
apt-get update && \
apt-get upgrade -yqq && \
npm update --global npm
WORKDIR /opt/harrybrwn.github.io
COPY ./package.json ./pnpm-workspace.yaml ./pnpm-lock.yaml ./
COPY packages ./packages
RUN pnpm install
COPY .git .git
COPY astro.config.mjs tsconfig.json ./
COPY src/ src
COPY public/ public
COPY content/ content
RUN pnpm run astro sync
FROM builder as server-builder
COPY . .
RUN pnpm build:server
FROM builder as static-builder
RUN pnpm build
#
# Static files
#
FROM scratch as static
COPY --from=static-builder /opt/harrybrwn.github.io/dist /
#
# Nginx
#
FROM nginx:${NGINX_VERSION}-alpine as nginx
COPY --from=static-builder /opt/harrybrwn.github.io/dist /var/www/harrybrwn.github.io
COPY config/nginx/ /etc/nginx/
# Just for lols
RUN sed -i 's/Server: nginx/Server: butts/g' /usr/sbin/nginx
ENV NGINX_ENVSUBST_TEMPLATE_SUFFIX=".conf"
ENV SERVER_HOST='_ localhost' SERVER_PORT='80' NGINX_GZIP='off'
CMD [ "nginx", "-g", "daemon off;" ]
#
# Server
#
FROM node:${NODE_VERSION}-alpine as server
WORKDIR /opt/harrybrwn.github.io/
COPY --from=server-builder /opt/harrybrwn.github.io .
ENV HOST=0.0.0.0
ENTRYPOINT ["node"]
#CMD ["node_modules/.bin/server"]
CMD ["packages/server/dist/index.js"]