Skip to content

Commit bb958f6

Browse files
authored
Add some voulmizer to the folicles (#60)
* Add some voulmizer to the folicles * Specify node_env for all the ci jobs * Expose node_env in the server
1 parent 1fe8911 commit bb958f6

16 files changed

+1388
-28
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules

.github/actions/build/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ inputs:
1111
username:
1212
required: false
1313
description: "Username for the registry"
14+
node_env:
15+
required: false
16+
description: "Node environment"
17+
default: "production"
1418

1519
outputs:
1620
tags:
@@ -78,3 +82,4 @@ runs:
7882
cache-to: type=gha,mode=max
7983
build-args: |
8084
VERSION=${{ steps.meta.outputs.tags }}
85+
NODE_ENV=${{ inputs.node_env }}

.github/workflows/deploy.development.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
push: true
2424
username: ${{ github.actor}}
2525
password: ${{ secrets.GITHUB_TOKEN }}
26+
node_env: production
2627

2728
- name: Deploy
2829
uses: ./.github/actions/deploy

.github/workflows/deploy.production.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
push: true
2424
username: ${{ github.actor}}
2525
password: ${{ secrets.GITHUB_TOKEN }}
26+
node_env: production
2627

2728
- name: Deploy
2829
uses: ./.github/actions/deploy

.github/workflows/deploy.staging.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
push: true
2222
username: ${{ github.actor}}
2323
password: ${{ secrets.GITHUB_TOKEN }}
24+
node_env: production
2425

2526
- name: Deploy
2627
uses: ./.github/actions/deploy

.github/workflows/publish.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Publish
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
node_env:
7+
description: 'Node environment'
8+
required: true
9+
default: 'production'
510

611
permissions:
712
contents: read
@@ -19,6 +24,7 @@ jobs:
1924
push: true
2025
username: ${{ github.actor }}
2126
password: ${{ secrets.GITHUB_TOKEN }}
27+
node_env: ${{ inputs.node_env }}
2228
- name: Notify (success)
2329
if: success()
2430
uses: ./.github/actions/slack

.github/workflows/test.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- uses: ./.github/actions/build
17-
id: build
16+
- id: build
17+
uses: ./.github/actions/build
18+
with:
19+
node_env: development
1820
- name: Test
1921
uses: ./.github/actions/run
2022
with:
@@ -28,8 +30,10 @@ jobs:
2830
runs-on: ubuntu-latest
2931
steps:
3032
- uses: actions/checkout@v4
31-
- uses: ./.github/actions/build
32-
id: build
33+
- id: build
34+
uses: ./.github/actions/build
35+
with:
36+
node_env: development
3337
- name: Lint
3438
uses: ./.github/actions/run
3539
with:

.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
dist
2-
node_modules
1+
dist/**
2+
node_modules/**
3+
4+
5+
.npm
6+
.bash_history
7+
.cache

Dockerfile

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,50 @@
1+
ARG HOME=/app UID=9500 GID=9500 VERSION="base"
2+
ARG NODE_ENV=production
3+
4+
# Define the base image, here we are root.
15
FROM node:18 as base
26

3-
WORKDIR /app
7+
RUN touch /is-docker
8+
9+
# Define the user and working directory, everything from this is user land
10+
FROM base as user
11+
12+
ARG HOME UID GID
13+
14+
RUN <<EOF
15+
groupadd -g ${GID} user
16+
useradd -u ${UID} -g ${GID} -s /sbin/nologin -d ${HOME} user
17+
EOF
18+
19+
USER user
20+
WORKDIR ${HOME}
21+
22+
FROM user as build
423

5-
RUN --mount=type=bind,src=package.json,dst=/app/package.json \
6-
npm install
24+
ARG HOME
25+
# Always development for building as we need to build the code
26+
ENV NODE_ENV=development
727

828
RUN \
9-
--mount=type=bind,src=package.json,dst=/app/package.json \
10-
--mount=type=bind,src=src,dst=/app/src/ \
11-
--mount=type=bind,src=tsconfig.json,dst=/app/tsconfig.json \
12-
npm run build
29+
--mount=type=bind,source=src,target=${HOME}/src \
30+
--mount=type=bind,source=package.json,target=${HOME}/package.json \
31+
--mount=type=bind,source=package-lock.json,target=${HOME}/package-lock.json \
32+
--mount=type=bind,source=tsconfig.json,target=${HOME}/tsconfig.json \
33+
<<EOF
34+
npm install --loglevel=verbose --no-save
35+
npm run build
36+
EOF
1337

14-
FROM base as final
38+
FROM user as final
1539

16-
ARG VERSION="base"
40+
ARG HOME VERSION NODE_ENV
1741

18-
ENV VERSION=${VERSION}
42+
ENV VERSION=${VERSION} NODE_ENV=${NODE_ENV}
1943

20-
COPY --from=base /app/dist /app/dist
21-
COPY package.json /app/package.json
44+
COPY --from=build ${HOME}/dist ${HOME}/dist
45+
COPY package.json package-lock.json ${HOME}/
2246

23-
RUN npm i --omit=dev --no-save
47+
RUN npm install --loglevel=verbose --no-save
2448

2549
EXPOSE 3000
2650

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.PHONY: default
2+
default: help
3+
4+
.PHONY: up
5+
up: ## Build and start containers
6+
mkdir -p node_modules
7+
mkdir -p dist
8+
docker compose up -d --build
9+
10+
.PHONY: build
11+
build: ## Build the app container
12+
docker compose build --no-cache --progress=plain
13+
14+
.PHONY: down
15+
down: ## Stop and remove containers, networks, images, and volumes
16+
docker compose down $(ARGS)
17+
18+
.PHONY: clean
19+
clean: ## Remove all containers, networks, images, and volumes
20+
make down ARGS="--rmi all --volumes"
21+
docker builder prune -af
22+
23+
.PHONY: shell
24+
shell: ## Access to the shell of the app docker container
25+
docker compose exec app /bin/bash
26+
27+
.PHONY: install
28+
install: ## Install dependencies
29+
docker compose exec app npm install $(ARGS) --loglevel=verbose
30+
31+
.PHONY: test
32+
test: ## Run tests
33+
docker compose exec app npm test $(ARGS)
34+
35+
.PHONY: help
36+
help:
37+
@echo "Please use 'make <target>' where <target> is one of the following commands.\n"
38+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
39+

0 commit comments

Comments
 (0)