diff --git a/.gitignore b/.gitignore index 1e9062d..d7fd2f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,12 @@ +# Global ignores **/node_modules/ **/.cache/ **/dist/ + +# Backend ignores +backend/backend.tar +backend/backend.tgz + +# Server ignores +server/*.pem +server/db/ \ No newline at end of file diff --git a/backend/Makefile b/backend/Makefile index dba9e46..af143ec 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -3,17 +3,28 @@ node_modules: WEBPACK_BUILD := ./node_modules/.bin/webpack-cli --config webpack.config.js +dist/bundle.js: prod .PHONY: prod prod: - ${WEBPACK_BUILD} --env.NODE_ENV=production + ${WEBPACK_BUILD} --mode production .PHONY: dev dev: - ${WEBPACK_BUILD} --env.NODE_ENV=development + ${WEBPACK_BUILD} --mode development .PHONY: start start: dev node dist/bundle.js -dockerfile: dist/bundle.js - sudo docker build -t lateinicus/server -f Dockerfile dist/ +VERSION := $(shell cat package.json | jq -r ".version") +CONTAINER_TAG := "lateinicus/server:${VERSION}" +container: dist/bundle.js + @echo Building the container + cp wait-for dist/ + sudo docker build -t ${CONTAINER_TAG} -f Dockerfile dist/ + rm -f dist/wait-for + + @echo Exporting the container + sudo docker save ${CONTAINER_TAG} > backend.tar + tar -czf backend.tgz backend.tar + rm -f backend.tar diff --git a/backend/webpack.config.js b/backend/webpack.config.js index 6c95497..d00e34d 100644 --- a/backend/webpack.config.js +++ b/backend/webpack.config.js @@ -1,13 +1,12 @@ const path = require("path"); -module.exports = env => { - const production = env.NODE_ENV || "production"; +module.exports = (env, mode) => { + const production = mode === "production"; return { entry: "./src/main.ts", devtool: production ? "source-map": "inline-source-map", target: "node", - mode: env.NODE_ENV, module: { rules: [