0
0
Fork 0

Add the neccesary docker files for operation

This commit is contained in:
Oliver-Akins 2023-08-26 20:42:01 -06:00
parent d7ef85fd30
commit 2d8d6f4aa0
4 changed files with 44 additions and 39 deletions

16
docker-compose.yaml Normal file
View file

@ -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"

27
dockerfile Normal file
View file

@ -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" ]

View file

@ -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

View file

@ -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. */