Merge pull request #321 from lucasshiva/nginx-support
Use nginx instead of vite preview for production builds
This commit is contained in:
commit
a5e765f0b4
3 changed files with 26 additions and 11 deletions
20
Dockerfile
20
Dockerfile
|
|
@ -1,5 +1,5 @@
|
|||
# Node Alpine -- multi-arch (amd64 + arm64)
|
||||
FROM node:lts-alpine
|
||||
FROM oven/bun:1.3.10-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
|
@ -7,12 +7,6 @@ WORKDIR /app
|
|||
RUN apk add --no-cache wget curl bash
|
||||
RUN apk add --no-cache python3 make g++ && ln -sf python3 /usr/bin/python
|
||||
|
||||
# Install Bun
|
||||
RUN curl -fsSL https://bun.sh/install | bash
|
||||
|
||||
# Add Bun to PATH so it can be used in subsequent steps
|
||||
ENV PATH="/root/.bun/bin:${PATH}"
|
||||
|
||||
# Copy package files first for caching
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
|
|
@ -25,8 +19,14 @@ COPY . .
|
|||
# Build the project (Bun is now available for "bun x neu build")
|
||||
RUN bun run build
|
||||
|
||||
# Expose Vite preview port
|
||||
# Serve with nginx
|
||||
FROM nginx:1.28.2-alpine
|
||||
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Expose the nginx port
|
||||
EXPOSE 4173
|
||||
|
||||
# Run the built project
|
||||
CMD ["bun", "run", "preview", "--", "--host", "0.0.0.0"]
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ services:
|
|||
networks:
|
||||
- monochrome-network
|
||||
healthcheck:
|
||||
test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:4173/health']
|
||||
test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:4173/']
|
||||
interval: 30s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
|
|
|
|||
15
nginx.conf
Normal file
15
nginx.conf
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
server {
|
||||
listen 4173;
|
||||
listen [::]:4173;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location ~* \.(?:css|js|mjs|map|json|wasm|mp3|flac|wav|ogg|png|jpg|jpeg|svg|webp|ico|gz|br|utf|ttf|woff2?)$ {
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue