diff --git a/Dockerfile b/Dockerfile index f8a6f26..8f3062e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,16 @@ -FROM node:22-slim AS builder -WORKDIR /usr/src/app -COPY package.json . -COPY package-lock.json* . -RUN npm ci +# build with nodejs +FROM node:25.8-bullseye-slim AS build +ENV NODE_ENV production +WORKDIR /app +COPY . /app +RUN mkdir -p dist node_modules +RUN chown -R node:node . +USER node +RUN NODE_ENV=development npm i +RUN npx quartz build -FROM node:22-slim -WORKDIR /usr/src/app -COPY --from=builder /usr/src/app/ /usr/src/app/ -COPY . . -CMD ["npx", "quartz", "build", "--serve"] +# serve compiled files with local nginx config +FROM nginx:alpine +WORKDIR /app +COPY --from=build /app/public . +COPY ./nginx.conf /etc/nginx/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..24fc031 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + app: + container_name: nginx-dauntless + image: nginx-dauntless + build: + context: . + dockerfile: Dockerfile + restart: always + ports: + - "9929:8080" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..afec279 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,22 @@ +events { + worker_connections 1024; +} + +http { + include mime.types; + sendfile on; + + server { + listen 8080; + listen [::]:8080; + + resolver 127.0.0.11; + autoindex off; + + server_name _; + server_tokens off; + + root /app; + gzip_static on; + } +}