build: Improve the backend Makefile

This commit is contained in:
Alexander Polynomdivision 2018-10-03 21:04:30 +02:00
parent 4857067481
commit 8cf4c3f5bc
3 changed files with 26 additions and 7 deletions

9
.gitignore vendored
View File

@ -1,3 +1,12 @@
# Global ignores
**/node_modules/
**/.cache/
**/dist/
# Backend ignores
backend/backend.tar
backend/backend.tgz
# Server ignores
server/*.pem
server/db/

View File

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

View File

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