build: Improve the backend Makefile
This commit is contained in:
parent
4857067481
commit
8cf4c3f5bc
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,3 +1,12 @@
|
|||||||
|
# Global ignores
|
||||||
**/node_modules/
|
**/node_modules/
|
||||||
**/.cache/
|
**/.cache/
|
||||||
**/dist/
|
**/dist/
|
||||||
|
|
||||||
|
# Backend ignores
|
||||||
|
backend/backend.tar
|
||||||
|
backend/backend.tgz
|
||||||
|
|
||||||
|
# Server ignores
|
||||||
|
server/*.pem
|
||||||
|
server/db/
|
@ -3,17 +3,28 @@ node_modules:
|
|||||||
|
|
||||||
WEBPACK_BUILD := ./node_modules/.bin/webpack-cli --config webpack.config.js
|
WEBPACK_BUILD := ./node_modules/.bin/webpack-cli --config webpack.config.js
|
||||||
|
|
||||||
|
dist/bundle.js: prod
|
||||||
.PHONY: prod
|
.PHONY: prod
|
||||||
prod:
|
prod:
|
||||||
${WEBPACK_BUILD} --env.NODE_ENV=production
|
${WEBPACK_BUILD} --mode production
|
||||||
|
|
||||||
.PHONY: dev
|
.PHONY: dev
|
||||||
dev:
|
dev:
|
||||||
${WEBPACK_BUILD} --env.NODE_ENV=development
|
${WEBPACK_BUILD} --mode development
|
||||||
|
|
||||||
.PHONY: start
|
.PHONY: start
|
||||||
start: dev
|
start: dev
|
||||||
node dist/bundle.js
|
node dist/bundle.js
|
||||||
|
|
||||||
dockerfile: dist/bundle.js
|
VERSION := $(shell cat package.json | jq -r ".version")
|
||||||
sudo docker build -t lateinicus/server -f Dockerfile dist/
|
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
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
module.exports = env => {
|
module.exports = (env, mode) => {
|
||||||
const production = env.NODE_ENV || "production";
|
const production = mode === "production";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
entry: "./src/main.ts",
|
entry: "./src/main.ts",
|
||||||
devtool: production ? "source-map": "inline-source-map",
|
devtool: production ? "source-map": "inline-source-map",
|
||||||
target: "node",
|
target: "node",
|
||||||
mode: env.NODE_ENV,
|
|
||||||
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
Reference in New Issue
Block a user