From 2d8d6f4aa0bfcef9f6b526a337bdbbc174dae8f1 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sat, 26 Aug 2023 20:42:01 -0600 Subject: [PATCH] Add the neccesary docker files for operation --- docker-compose.yaml | 16 ++++++++++++++++ dockerfile | 27 +++++++++++++++++++++++++++ makefile | 38 -------------------------------------- tsconfig.json | 2 +- 4 files changed, 44 insertions(+), 39 deletions(-) create mode 100644 docker-compose.yaml create mode 100644 dockerfile delete mode 100644 makefile diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..54093be --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,16 @@ +version: "3" +name: "chatman" +services: + + api: + build: + dockerfile: "dockerfile" + target: "dev" + ports: + - "6969:6969" + environment: + NODE_ENV: "dev" + volumes: + - "./data.json:/app/data.json" + - "./site:/app/site" + - "./word-lists:/app/word-lists" \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..a864a87 --- /dev/null +++ b/dockerfile @@ -0,0 +1,27 @@ +from node:19 as base + +workdir /app + +expose 6969 + +run npm install --global typescript@4 + +copy package*.json tsconfig.json /app/ +run npm install + +healthcheck CMD curl -f http://localhost:6969/health + +copy ./src /app/src +run tsc + + +from base as dev +run npm install +cmd [ "/bin/bash" ] + + +from base as prod +copy ./docs /app/docs +run npm install --omit=dev +run rm -rf src tsconfig.json +cmd [ "NODE_ENV=production", "node", "dist/main.js" ] \ No newline at end of file diff --git a/makefile b/makefile deleted file mode 100644 index a44e63b..0000000 --- a/makefile +++ /dev/null @@ -1,38 +0,0 @@ -# The node executables to care about -NODE = node -PACKAGE_MANAGER = pnpm - -# The folder that Typescript compiles the Javascript into -OUT_DIR = dist - -#=============================================================================# -# DO NOT CHANGE ANYTHING BELOW THIS LINE -#=============================================================================# - -BIN := $(shell $(PACKAGE_MANAGER) bin) - -.PHONY: $(OUT_DIR) dev prod run rund interfaces clean - - -$(OUT_DIR): - tsc --outDir $(OUT_DIR) - -interfaces: - -$(BIN)/ts-node generateInterfaces.ts 2>/dev/null - @$(RM) src/types/index.ts - @echo Finished creating interfaces - -dev: $(OUT_DIR) - NODE_ENV=development $(NODE) $(OUT_DIR)/main.js - -prod: $(OUT_DIR) - NODE_ENV=production $(NODE) $(OUT_DIR)/main.js - -rund: - NODE_ENV=development $(NODE) $(OUT_DIR)/main.js - -run: - NODE_ENV=production $(NODE) $(OUT_DIR)/main.js - -clean: - $(RM) -rf $(OUT_DIR) tsconfig.tsbuildinfo \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index edb5e35..720d080 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -51,7 +51,7 @@ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ + "outDir": "./dist", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */