docker nginx

This commit is contained in:
Irwan Cahyono 2025-08-07 10:06:51 +07:00
parent dec8d7d9c7
commit 3fb2a522ea
4 changed files with 32 additions and 11 deletions

12
.dockerignore Normal file
View File

@ -0,0 +1,12 @@
node_modules
.dockerignore
.git
.gitignore
.vscode
.env
*.log
*.md
Dockerfile
README.md
nuxt.config.ts
tsconfig.json

View File

@ -1,4 +1,4 @@
# Tahap build
# Dockerfile untuk SPA Nuxt 3
FROM node:24-alpine AS builder
WORKDIR /app
@ -10,15 +10,13 @@ COPY . .
RUN npm run build
# Tahap production
FROM node:24-alpine AS runner
# Gunakan NGINX untuk menyajikan SPA
FROM nginx:1.29.0-alpine-slim
WORKDIR /app
# Salin hasil build ke folder root nginx
COPY --from=builder /app/.output/public /usr/share/nginx/html
RUN npm install -g serve
# Salin konfigurasi khusus NGINX untuk SPA (opsional tapi direkomendasikan)
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/.output/public ./public
EXPOSE 3000
CMD ["serve", "-s", "public", "-l", "3000"]
EXPOSE 80

View File

@ -3,7 +3,7 @@ services:
build: .
container_name: nuxt-container
ports:
- "3000:3000"
- "3000:80"
env_file:
- .env
environment:

11
nginx.conf Normal file
View File

@ -0,0 +1,11 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}