Skip to content

Commit d319ca0

Browse files
committed
Update Makefile and docker setups
1 parent 27772d6 commit d319ca0

File tree

4 files changed

+35
-29
lines changed

4 files changed

+35
-29
lines changed

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM node:20-alpine
2+
3+
RUN apk update && apk add bash
4+
5+
RUN npm install -g npm@^9.0.0
6+
7+
WORKDIR /srv/app
8+
COPY package.json package-lock.json /srv/app/
9+
RUN cd /srv/app && npm install
10+
COPY . /srv/app/

Makefile

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,42 @@ help: ## List all make commands
55
@echo ' '
66

77
build: ## Build the project with -d and --no-recreate flags
8-
$(DOCKER_COMPOSE) up --build --no-recreate -d
8+
docker compose up --build --no-recreate -d
99

1010
install: ## Exec container and make npm install commands
11-
$(DOCKER_EXEC_TOOLS_APP) -c $(NODE_INSTALL)
11+
docker compose exec mct_web npm install
1212

13-
bundle: ## Run build npm command script
14-
$(DOCKER_EXEC_TOOLS_APP) -c $(BUNDLE_RUN)
13+
bundle:
14+
docker compose exec mct_web npm run bundle
1515

1616
clean: ## Remove all dist/ files
17-
$(DOCKER_EXEC_TOOLS_APP) -c $(CLEAN_RUN)
17+
docker compose exec mct_web rm -r dist/*
1818

19-
interact: ## Interact to install new packages or run specific commands in container
20-
$(DOCKER_EXEC_TOOLS_APP)
19+
bash: ## Interact to install new packages or run specific commands in container
20+
docker compose exec -it mct_web bash
2121

2222
dev: # Internal command to run dev npm command script
23-
$(DOCKER_EXEC_TOOLS_APP) -c $(SERVER_RUN)
23+
docker compose exec -it mct_web npm run development
2424

2525
up: ## Run up -d Docker command container will wait for interactions
26-
$(DOCKER_COMPOSE) up -d
26+
docker compose up -d
2727

2828
start: up dev ## Up the docker env and run the npm run dev it to
2929

3030
first: build install dev ## Build the env, up it and run the npm install and then run npm run dev it to
3131

32-
stop: $(ROOT_DIR)/compose.yml ## Stop and remove containers
33-
$(DOCKER_COMPOSE) kill
34-
$(DOCKER_COMPOSE) rm --force
32+
stop: ./compose.yml ## Stop and remove containers
33+
docker compose kill
34+
docker compose rm --force
3535
restart: stop start dev ## Stop and restart container
3636

37-
clear: stop $(ROOT_DIR)/compose.yml ## Stop and remove container and orphans
38-
$(DOCKER_COMPOSE) down -v --remove-orphans
37+
types: ## Run type check and generator
38+
docker compose exec mct_web npm run types
39+
40+
types-watch: ## Run type check and generator
41+
docker compose exec mct_web npm run types-watch
42+
43+
clear: stop ./compose.yml ## Stop and remove container and orphans
44+
docker compose down -v --remove-orphans
45+
46+
.PHONY: bash build clean help logs start stop types types-watch

compose.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
version: "3.4"
2-
31
services:
4-
vite_docker:
5-
image: node:alpine
6-
container_name: "${DOCKER_NAME}"
2+
mct_web:
3+
build: .
4+
image: mct:latest
75
entrypoint: /bin/sh
86
env_file:
97
- .env

env.example

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,3 @@ HOST_PORT=5173
44
CONTAINER_PORT=5173
55
SERVER_HOST_PORT=5000
66
SERVER_CONTAINER_PORT=5000
7-
DOCKER_NAME=mct_docker
8-
9-
CURRENT_DIR=$(patsubst %/,%,$(dir $(realpath $(firstword $(MAKEFILE_LIST)))))
10-
ROOT_DIR=$(CURRENT_DIR)
11-
DOCKER_COMPOSE=docker compose
12-
DOCKER_EXEC_TOOLS_APP=docker exec -it $(DOCKER_NAME) sh
13-
NODE_INSTALL="npm i"
14-
BUNDLE_RUN="npm run build"
15-
CLEAN_RUN="rm -r dist/*"
16-
SERVER_RUN="npm run development"

0 commit comments

Comments
 (0)