docker deploy
This commit is contained in:
parent
f0656b8d72
commit
10d4ed02c4
4 changed files with 52 additions and 1 deletions
16
Dockerfile
Normal file
16
Dockerfile
Normal file
|
@ -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
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
|
@ -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"
|
22
nginx.conf
Normal file
22
nginx.conf
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,8 @@
|
||||||
"start:site": "npx @11ty/eleventy --serve",
|
"start:site": "npx @11ty/eleventy --serve",
|
||||||
"build": "npx @11ty/eleventy",
|
"build": "npx @11ty/eleventy",
|
||||||
"postbuild": "npx postcss styles.css -o _site/styles.css --env production",
|
"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": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
Loading…
Add table
Reference in a new issue