Skip to content

Commit 8686ed5

Browse files
committed
fix: build with pkg + docker
1 parent ef13ffd commit 8686ed5

File tree

10 files changed

+161
-14
lines changed

10 files changed

+161
-14
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
distribs/
4+
5+
.env

.github/workflows/docker-image.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Docker Image CI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
steps:
15+
- name: Checkout the code
16+
uses: actions/checkout@v2
17+
18+
- name: Build docker
19+
uses: Libertech-FR/lt-actions/docker-image@main
20+
with:
21+
repository: ${{ github.repository }}
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pkg.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Build and release
2+
23
on:
3-
push:
4-
tags:
5-
- 'v*.*.*'
4+
release:
5+
types: [published]
6+
67
jobs:
78
build:
89
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_increment:
7+
description: 'La version a incrémenter (major, minor, patch)'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- 'major'
13+
- 'minor'
14+
- 'patch'
15+
build_docker_image:
16+
description: "Construire l'image docker ?"
17+
required: true
18+
default: true
19+
type: boolean
20+
latest:
21+
description: "Tagger l'image docker avec le tag 'latest' ?"
22+
required: true
23+
default: true
24+
type: boolean
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: write
31+
packages: write
32+
33+
steps:
34+
- name: Build docker
35+
uses: Libertech-FR/lt-actions/release@main
36+
with:
37+
version_increment: ${{ github.event.inputs.version_increment }}
38+
build_docker_image: ${{ github.event.inputs.build_docker_image }}
39+
latest: ${{ github.event.inputs.latest }}
40+
repository: ${{ github.repository }}
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
access_token: ${{ secrets.GITHUB_TOKEN }}
44+
github_token: ${{ secrets.GITHUB_TOKEN }}
45+
# Optional parameters, thoses are default values :
46+
registry: 'ghcr.io'
47+
context: .

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ lerna-debug.log*
3232
!.vscode/settings.json
3333
!.vscode/tasks.json
3434
!.vscode/launch.json
35-
!.vscode/extensions.json
35+
!.vscode/extensions.json
36+
37+
# Docker
38+
docker-compose.yml

.yarnclean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!**/yaml/dist/**/doc
2+
!yaml/**/doc/*

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM node:18-bookworm-slim as builder
2+
3+
WORKDIR /data
4+
5+
COPY . .
6+
7+
RUN yarn install \
8+
--prefer-offline \
9+
--frozen-lockfile \
10+
--non-interactive \
11+
--production=false
12+
13+
RUN yarn run build
14+
15+
FROM node:18-bookworm-slim as production
16+
17+
ARG NODE_ENV=production
18+
ENV NODE_ENV=${NODE_ENV}
19+
20+
WORKDIR /data
21+
22+
ADD package.json .
23+
ADD *.lock .
24+
25+
RUN yarn install \
26+
--prefer-offline \
27+
--pure-lockfile \
28+
--non-interactive \
29+
--production=true \
30+
&& yarn cache clean \
31+
&& yarn autoclean --init \
32+
&& yarn autoclean --force
33+
34+
COPY --from=builder /data/dist ./dist
35+
36+
CMD ["yarn", "start:prod"]

Makefile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,25 @@ help:
88
@grep -E '^[-a-zA-Z0-9_\.\/]+:.*?## .*$$' $(MAKEFILE_LIST) \
99
| sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}'
1010

11+
build: ## Build development container
12+
@docker compose build $(DEV_CONTAINER_NAME)
13+
1114
dev: ## Run development server
1215
@docker compose run -d --rm \
1316
--service-ports \
1417
--use-aliases \
1518
--name $(DEV_CONTAINER_NAME) \
1619
$(DEV_CONTAINER_NAME) yarn start:dev
1720

21+
exec: ## Execute a command in the development container
22+
@docker compose run -it --rm $(DEV_CONTAINER_NAME) bash
23+
24+
install: ## Execute a command in the development container
25+
@docker compose run -it --rm $(DEV_CONTAINER_NAME) yarn install
26+
1827
dbs: ## Run dependencies for development
28+
@docker volume create $(APPNAME)-mongodb
29+
@docker compose up -d $(APPNAME)-redis $(APPNAME)-mongo
1930
@docker volume create $(APPNAME)-redis
2031
@docker run -d --rm \
2132
--name $(APPNAME)-redis \
@@ -29,16 +40,6 @@ dbs: ## Run dependencies for development
2940
--health-cmd="redis-cli ping || exit 1" \
3041
redis || true
3142

32-
exec: ## Execute a command in the development container
33-
@docker compose run -it --rm $(DEV_CONTAINER_NAME) bash
34-
35-
install: ## Execute a command in the development container
36-
@docker compose run -it --rm $(DEV_CONTAINER_NAME) yarn install
37-
38-
dbs: ## Run dependencies for development
39-
@docker volume create $(APPNAME)-mongodb
40-
@docker compose up -d $(APPNAME)-redis $(APPNAME)-mongo
41-
4243
stop: ## Stop all containers
4344
@docker compose down --remove-orphans
4445
@docker compose rm -f

docker-compose.development.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '3'
2+
3+
services:
4+
sesame-daemon:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
restart: "no"
9+
container_name: ${APP_NAME:-sesame-daemon}
10+
volumes:
11+
- ./:/data
12+
networks: ['dev']
13+
environment:
14+
- NODE_ENV=development
15+
extra_hosts:
16+
- "host.docker.internal:host-gateway"
17+
command: yarn start:debug
18+
19+
networks:
20+
dev:
21+
external: true

docker-compose.production.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: '3'
2+
3+
services:
4+
sesame-daemon:
5+
image: ghcr.io/libertech-fr/sesame-daemon:latest
6+
container_name: ${APP_NAME:-sesame-daemon}
7+
restart: "unless-stopped"
8+
env_file: ./volumes/api/.env

0 commit comments

Comments
 (0)