build: modify dockerfile to serve demo instance as static webpage
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
node_modules
|
||||
server/node_modules
|
||||
Dockerfile
|
||||
.env
|
39
Dockerfile
39
Dockerfile
@ -1,20 +1,37 @@
|
||||
FROM node:lts-alpine
|
||||
FROM node:lts-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache --update git
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
WORKDIR /app/server
|
||||
COPY server/package*.json ./
|
||||
RUN npm ci
|
||||
COPY server/prisma/schema.prisma ./prisma/schema.prisma
|
||||
RUN npx prisma generate
|
||||
|
||||
WORKDIR /app
|
||||
COPY ./ ./
|
||||
RUN npm run build
|
||||
|
||||
WORKDIR /app/server
|
||||
CMD ["node", "index.js"]
|
||||
FROM nginx
|
||||
COPY <<EOF /etc/nginx/conf.d/default.conf
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index non-existent-to-prevent-caching.html;
|
||||
try_files \$uri @index;
|
||||
}
|
||||
|
||||
location @index {
|
||||
root /usr/share/nginx/html;
|
||||
add_header Cache-Control no-cache;
|
||||
expires 0;
|
||||
try_files /index.html =404;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
@ -3,20 +3,4 @@ services:
|
||||
app:
|
||||
build: .
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres
|
||||
depends_on:
|
||||
- db
|
||||
env_file:
|
||||
- ./server/.env
|
||||
command: /bin/sh -c "npx prisma db push && node index.js"
|
||||
db:
|
||||
image: postgres
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
- 3000:80
|
Reference in New Issue
Block a user