From 10d4ed02c4ea2571cbf14ac654e3977396b899d2 Mon Sep 17 00:00:00 2001 From: Ava Gaiety W Date: Tue, 5 Mar 2024 20:39:14 +0000 Subject: [PATCH] docker deploy --- Dockerfile | 16 ++++++++++++++++ docker-compose.yml | 12 ++++++++++++ nginx.conf | 22 ++++++++++++++++++++++ package.json | 3 ++- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d5bfd5b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# build with nodejs +FROM node:16.17.0-bullseye-slim AS build +ENV NODE_ENV production +WORKDIR /app +COPY . /app +RUN mkdir -p _site node_modules +RUN chown -R node:node . +USER node +RUN NODE_ENV=development npm ci +RUN npm run build + +# serve compiled files with local nginx config +FROM nginx:alpine +WORKDIR /app +COPY --from=build /app/_site . +COPY ./nginx.conf /etc/nginx/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..abedf27 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3.9" + +services: + app: + container_name: nginx-portfolio + image: nginx-portfolio + build: + context: . + dockerfile: Dockerfile + restart: always + ports: + - "9997: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; + } +} diff --git a/package.json b/package.json index bbe23a7..f85866b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "start:site": "npx @11ty/eleventy --serve", "build": "npx @11ty/eleventy", "postbuild": "npx postcss styles.css -o _site/styles.css --env production", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "deploy": "docker compose up --build -d" }, "repository": { "type": "git",