mirror of
https://codeberg.org/JasterV/jaster.xyz.git
synced 2026-04-26 18:10:01 +00:00
feat: Docker build
This commit is contained in:
parent
3a1dca9817
commit
e50b7282f2
4 changed files with 84 additions and 2 deletions
18
.dockerignore
Normal file
18
.dockerignore
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
node_modules/
|
||||
|
||||
dist/
|
||||
|
||||
Dockerfile*
|
||||
|
||||
.dockerignore
|
||||
|
||||
.git
|
||||
|
||||
.vscode/
|
||||
|
||||
.prettierrc.mjs
|
||||
|
||||
.gitignore
|
||||
|
||||
README.md
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,6 +1,8 @@
|
|||
# build output
|
||||
dist/
|
||||
|
||||
.vscode/
|
||||
|
||||
# generated types
|
||||
.astro/
|
||||
|
||||
|
|
@ -17,5 +19,3 @@ pnpm-debug.log*
|
|||
.env
|
||||
.env.production
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
||||
|
|
|
|||
33
Dockerfile
Normal file
33
Dockerfile
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# use the official Bun image
|
||||
# see all versions at https://hub.docker.com/r/oven/bun/tags
|
||||
FROM oven/bun:1 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/dev && mkdir /temp/prod
|
||||
WORKDIR /temp/dev
|
||||
COPY package.json bun.lockb ./
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
# install with --production (exclude devDependencies)
|
||||
WORKDIR /temp/prod
|
||||
COPY package.json bun.lockb ./
|
||||
RUN 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/dev/node_modules node_modules
|
||||
COPY . .
|
||||
|
||||
# build
|
||||
ENV NODE_ENV=production
|
||||
RUN bun run build
|
||||
|
||||
# copy production dependencies and source code into final image
|
||||
FROM nginx:alpine AS runtime
|
||||
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=prerelease /usr/src/app/dist /usr/share/nginx/html
|
||||
EXPOSE 8080
|
||||
31
nginx/nginx.conf
Normal file
31
nginx/nginx.conf
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
worker_processes 1;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
include /etc/nginx/mime.types;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1000;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /404.html {
|
||||
root /usr/share/nginx/html;
|
||||
internal;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/index.html =404;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue