Skip to content

Commit 81696f8

Browse files
committed
fix structure makefile + release
1 parent aa481d0 commit 81696f8

File tree

2 files changed

+111
-1
lines changed

2 files changed

+111
-1
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
type: boolean
2525

2626
jobs:
27-
build:
27+
build-docker:
2828
runs-on: ubuntu-latest
2929
permissions:
3030
contents: write
@@ -45,3 +45,31 @@ jobs:
4545
# Optional parameters, thoses are default values :
4646
registry: 'ghcr.io'
4747
context: .
48+
49+
build-pkg:
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
- name: Use Node.js
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version: '18'
59+
- run: npm install -g yarn
60+
- run: yarn --frozen-lockfile
61+
- run: npm install --global pkg
62+
- run: yarn build
63+
# - run: curl -sf https://gobinaries.com/tj/node-prune | sh
64+
# - run: node-prune
65+
- name: Build
66+
run: pkg dist/main.js -o sesame-daemon --targets linux,macos,win -C Brotli
67+
- name: Release
68+
uses: softprops/action-gh-release@v1
69+
with:
70+
files: |
71+
sesame-daemon-linux
72+
sesame-daemon-macos
73+
sesame-daemon-win.exe
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
include .env
2+
IMG_NAME = "ghcr.io/libertech-fr/sesame-deamon"
3+
BASE_NAME = "sesame"
4+
APP_NAME = "sesame-deamon"
5+
PLATFORM = "linux/amd64"
6+
7+
.DEFAULT_GOAL := help
8+
help:
9+
@printf "\033[33mUsage:\033[0m\n make [target] [arg=\"val\"...]\n\n\033[33mTargets:\033[0m\n"
10+
@grep -E '^[-a-zA-Z0-9_\.\/]+:.*?## .*$$' $(MAKEFILE_LIST) \
11+
| sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}'
12+
13+
build: ## Build the container
14+
@docker build --platform $(PLATFORM) -t $(IMG_NAME) .
15+
16+
dev: ## Start development environment
17+
@docker run --rm -it \
18+
-e NODE_ENV=development \
19+
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
20+
--add-host host.docker.internal:host-gateway \
21+
--network dev \
22+
--platform $(PLATFORM) \
23+
--name $(APP_NAME) \
24+
-v $(CURDIR):/data \
25+
$(IMG_NAME) yarn start:dev
26+
27+
install: ## Install dependencies
28+
@docker run -it --rm \
29+
-e NODE_ENV=development \
30+
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
31+
--add-host host.docker.internal:host-gateway \
32+
--platform $(PLATFORM) \
33+
--network dev \
34+
-v $(CURDIR):/data \
35+
$(IMG_NAME) yarn install
36+
37+
exec: ## Run a shell in the container
38+
@docker run -it --rm \
39+
-e NODE_ENV=development \
40+
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
41+
--add-host host.docker.internal:host-gateway \
42+
--platform $(PLATFORM) \
43+
--network dev \
44+
-v $(CURDIR):/data \
45+
$(IMG_NAME) sh
46+
47+
dbs: ## Start databases
48+
@docker volume create $(BASE_NAME)-mongodb
49+
@docker run -d --rm \
50+
--name $(BASE_NAME)-mongodb \
51+
-v $(BASE_NAME)-mongodb:/data/db \
52+
-p 27017:27017 \
53+
-e MONGODB_REPLICA_SET_MODE=primary \
54+
-e MONGODB_REPLICA_SET_NAME=rs0 \
55+
-e ALLOW_EMPTY_PASSWORD=yes \
56+
--platform $(PLATFORM) \
57+
--network dev \
58+
--health-interval=5s \
59+
--health-timeout=3s \
60+
--health-start-period=5s \
61+
--health-retries=3 \
62+
--health-cmd="mongo --eval \"db.stats().ok\" || exit 1" \
63+
mongo:7.0 --replSet rs0 --wiredTigerCacheSizeGB 1.5 || true
64+
@docker volume create $(BASE_NAME)-redis
65+
@docker run -d --rm \
66+
--name $(BASE_NAME)-redis \
67+
-v $(BASE_NAME)-redis:/data \
68+
--platform $(PLATFORM) \
69+
--network dev \
70+
-p 6379:6379 \
71+
--health-interval=5s \
72+
--health-timeout=3s \
73+
--health-start-period=5s \
74+
--health-retries=3 \
75+
--health-cmd="redis-cli ping || exit 1" \
76+
redis || true
77+
@docker exec -it $(BASE_NAME)-mongodb mongosh --eval "rs.initiate({_id: 'rs0', members: [{_id: 0, host: '127.0.0.1:27017'}]})" || true
78+
79+
stop: ## Stop the container
80+
@docker stop $(APP_NAME) || true
81+
@docker stop $(BASE_NAME)-mongodb || true
82+
@docker stop $(BASE_NAME)-redis || true

0 commit comments

Comments
 (0)