diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8702580 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +# build with nodejs +FROM node:16.17.0-bullseye-slim +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 postinstall +RUN npm run prestart +CMD ["node", "./app.js"] diff --git a/README.md b/README.md index 565800c..993cfda 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ Inspired by [@morganastra](https://twitter.com/morganastra)'s [pronoun.is](https - [NodeJS](https://nodejs.org/en/) -```bash +```sh npm i # Installs Dependencies ``` ### Serving Locally -```bash +```sh npm start ``` @@ -21,11 +21,12 @@ npm start ### Deploy -```bash -npm build:css -npm start +```sh +npm run deploy ``` ### Testing -TODO +```sh +npm test +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..aa73e0a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3.9" + +services: + app: + container_name: pronoun-monster + image: pronoun-monster + build: + context: . + dockerfile: Dockerfile + restart: always + ports: + - "9995:3000" diff --git a/package.json b/package.json index 1a08b9a..eed9797 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,12 @@ "main": "app.js", "scripts": { "postinstall": "mkdir -p ./dist", - "start": "concurrently npm:serve:*", + "start": "node app.js", + "prestart": "npm run start:css && npm run start:svg && npm run start:images", + "start:css": "tailwindcss -i ./src/app.css -o ./dist/app.css", + "start:svg": "npm run build:svg", + "start:images": "npm run build:images", + "serve": "concurrently npm:serve:*", "build": "concurrently npm:build:*", "serve:handlebars": "node app.js", "serve:css": "tailwindcss -i ./src/app.css -o ./dist/app.css --watch", @@ -16,7 +21,8 @@ "build:images": "mkdir -p ./dist ./dist/images && cp ./src/images/* ./dist/images/", "test": "ava", "lint": "prettier --check .", - "prepare": "husky install" + "prepare": "husky install", + "deploy": "docker compose up --build -d" }, "repository": { "type": "git",