diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..924abb6 --- /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 dist 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/dist . +COPY ./nginx.conf /etc/nginx/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..307fc23 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3.9" + +services: + app: + container_name: nginx-gaiety-life + image: nginx-gaiety-life + build: + context: . + dockerfile: Dockerfile + restart: always + ports: + - "9998:8080" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..c738e06 --- /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 on; + + server_name _; + server_tokens off; + + root /app; + gzip_static on; + } +} diff --git a/package.json b/package.json index 532821e..942df53 100644 --- a/package.json +++ b/package.json @@ -2,29 +2,28 @@ "name": "gaiety-life", "version": "2.0.0", "description": "Gaiety's Blog", - "main": "index.js", "scripts": { - "build:styles": "tailwindcss -i ./styles/main.css -o ./_site/main.css", - "build:site": "eleventy", - "build": "npm run build:site & npm run build:styles", - "serve:styles": "npm run build:styles -- --watch", - "serve:site": "npm run build:site -- --serve", + "build": "eleventy", + "postbuild": "tailwindcss -i ./styles/main.css -o ./_site/main.css", + "serve:styles": "tailwindcss -i ./styles/main.css -o ./_site/main.css --watch", + "serve:site": "eleventy --serve", "serve": "concurrently \"npm run serve:site\" \"npm run serve:styles\"", - "start": "npm run serve" + "start": "npm run serve", + "deploy": "docker compose up --build -d" }, "repository": { "type": "git", - "url": "git+ssh://git@gitlab.com/gaiety/gaiety-life.git" + "url": "git+git@git.gay:gaiety/gaiety-life.git" }, "keywords": [ "blog" ], - "author": "Ava Gaiety W.", + "author": "Ava Gaiety W. (https://www.gaiety.me/)", "license": "The Unlicense", "bugs": { - "url": "https://gitlab.com/gaiety/gaiety-life/issues" + "url": "https://git.gay/gaiety/gaiety-life/issues" }, - "homepage": "https://gitlab.com/gaiety/gaiety-life#readme", + "homepage": "https://git.gay/gaiety/gaiety-life/src/branch/main/README.md", "devDependencies": { "@11ty/eleventy": "^2.0.1", "@11ty/eleventy-plugin-rss": "^1.1.2",