docker nginx
This commit is contained in:
parent
dec8d7d9c7
commit
3fb2a522ea
12
.dockerignore
Normal file
12
.dockerignore
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
node_modules
|
||||||
|
.dockerignore
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.vscode
|
||||||
|
.env
|
||||||
|
*.log
|
||||||
|
*.md
|
||||||
|
Dockerfile
|
||||||
|
README.md
|
||||||
|
nuxt.config.ts
|
||||||
|
tsconfig.json
|
||||||
18
Dockerfile
18
Dockerfile
@ -1,4 +1,4 @@
|
|||||||
# Tahap build
|
# Dockerfile untuk SPA Nuxt 3
|
||||||
FROM node:24-alpine AS builder
|
FROM node:24-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@ -10,15 +10,13 @@ COPY . .
|
|||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Tahap production
|
# Gunakan NGINX untuk menyajikan SPA
|
||||||
FROM node:24-alpine AS runner
|
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 80
|
||||||
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
CMD ["serve", "-s", "public", "-l", "3000"]
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ services:
|
|||||||
build: .
|
build: .
|
||||||
container_name: nuxt-container
|
container_name: nuxt-container
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:80"
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
11
nginx.conf
Normal file
11
nginx.conf
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user