fix(docker): update docker image

* Add missing PUB_ENV environment variable
* Copy `patches/` folder during build
* Use nginx for serving files

Co-authored-by: GitGitro <108683123+GitGitro@users.noreply.github.com>
This commit is contained in:
azurejelly 2025-02-10 20:59:00 -05:00
parent 21faba31f1
commit a55d5f41a9
No known key found for this signature in database
GPG Key ID: 78C7CB2FBB62D96D
4 changed files with 21 additions and 8 deletions

View File

@ -2,13 +2,16 @@ FROM oven/bun AS builder
WORKDIR /app
ARG PUB_ENV
ARG PUB_HOSTNAME
ARG PUB_PLAUSIBLE_URL
ENV PUB_ENV=${PUB_ENV}
ENV PUB_HOSTNAME=${PUB_HOSTNAME}
ENV PUB_PLAUSIBLE_URL=${PUB_PLAUSIBLE_URL}
COPY package.json ./
COPY patches/ ./patches
RUN bun install
@ -16,12 +19,8 @@ COPY . ./
RUN bun run build
FROM oven/bun:alpine
FROM nginx:stable-alpine
WORKDIR /app
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/build ./
EXPOSE 3000
CMD [ "bun", "run", "start" ]
COPY --from=builder /app/build /usr/share/nginx/html

View File

@ -57,6 +57,7 @@ This will build the site to the `build` folder. You can then start the server wi
Clone the repository, then build a Docker image with:
```shell
$ docker build -t not-nullptr/vert \
--build-arg PUB_ENV=production \
--build-arg PUB_HOSTNAME=vert.sh \
--build-arg PUB_PLAUSIBLE_URL=https://plausible.example.com .
```

View File

@ -6,6 +6,7 @@ services:
args:
PUB_HOSTNAME: "vert.sh"
PUB_PLAUSIBLE_URL: "https://plausible.example.com"
PUB_ENV: "production"
restart: unless-stopped
ports:
- 3000:3000
- 3000:80

12
nginx.conf Normal file
View File

@ -0,0 +1,12 @@
server {
listen 80;
server_name vert;
root /usr/share/nginx/html;
client_max_body_size 10M;
location / {
try_files $uri /index.html;
}
}