Skip to content

Commit 6f6ada0

Browse files
Fix build (#31)
* change dockerfile * change release
1 parent 6a6a080 commit 6f6ada0

File tree

4 files changed

+191
-46
lines changed

4 files changed

+191
-46
lines changed

.github/workflows/release.yml

Lines changed: 177 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ on:
99
default: 'patch'
1010
type: choice
1111
options:
12-
- 'major'
13-
- 'minor'
14-
- 'patch'
12+
- 'major'
13+
- 'minor'
14+
- 'patch'
1515
build_docker_image:
1616
description: "Construire l'image docker ?"
1717
required: true
@@ -24,49 +24,188 @@ on:
2424
type: boolean
2525

2626
jobs:
27-
build-service:
27+
pre-build:
2828
runs-on: ubuntu-latest
29-
permissions:
30-
contents: write
31-
packages: write
32-
actions: write
33-
pull-requests: write
34-
checks: write
35-
3629
steps:
37-
- name: Build docker
38-
uses: Libertech-FR/lt-actions/release@main
30+
- name: Checkout repository
31+
uses: actions/checkout@v2
3932
with:
40-
version_increment: ${{ github.event.inputs.version_increment }}
41-
build_docker_image: ${{ github.event.inputs.build_docker_image }}
42-
latest: ${{ github.event.inputs.latest }}
4333
repository: ${{ github.repository }}
44-
username: ${{ github.actor }}
45-
password: ${{ secrets.GITHUB_TOKEN }}
46-
github_token: ${{ secrets.ACTION_TOKEN }}
47-
# Optional parameters, thoses are default values :
34+
35+
- name: Checkout code
36+
uses: actions/checkout@v2
37+
38+
- name: Set up Git
39+
shell: bash
40+
run: |
41+
git config user.email "github@action.com"
42+
git config user.name "Github Action"
43+
echo ${{ secrets.GITHUB_TOKEN }} > token.txt
44+
git config credential.helper "store --file=token.txt"
45+
46+
- name: Update version
47+
shell: bash
48+
run: |
49+
echo NEW_VERSION=$(yarn version --${{ inputs.version_increment }} --json | jq -r '.data | select(contains("New version")) | split(":")[1] | gsub(" ";"")') >> $GITHUB_ENV
50+
env:
51+
REF: ${{ github.ref }}
52+
53+
- name: Push to protected branch
54+
uses: CasperWA/push-protected@v2
55+
with:
56+
token: ${{ secrets.ACTION_TOKEN }}
57+
branch: main
58+
unprotect_reviews: true
59+
tags: true
60+
61+
- name: Publish release
62+
uses: ncipollo/release-action@v1
63+
with:
64+
name: Release ${{ env.NEW_VERSION }}
65+
commit: ${{ env.REF }}
66+
draft: false
67+
prerelease: false
68+
generateReleaseNotes: true
69+
token: ${{ secrets.GITHUB_TOKEN }}
70+
makeLatest: ${{ inputs.latest }}
71+
tag: ${{ env.NEW_VERSION }}
72+
73+
- name: Get repo name
74+
shell: bash
75+
id: get_repo_name
76+
run: |
77+
echo "REPO_NAME=$(basename "${{ github.repository }}")" >> $GITHUB_ENV
78+
79+
- name: Get repo full name
80+
shell: bash
81+
id: get_repo_full_name
82+
run: |
83+
FULL_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
84+
echo "REPO_FULL_NAME=$FULL_NAME" >> $GITHUB_ENV
85+
86+
- name: Get current date and time
87+
shell: bash
88+
id: get_current_date_time
89+
run: |
90+
echo "CURRENT_DATE_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
91+
92+
build-service:
93+
runs-on: ubuntu-latest
94+
needs: pre-build
95+
if: ${{ inputs.build_docker_image == 'true' }}
96+
steps:
97+
- name: Define service tags
98+
shell: bash
99+
id: define_tags
100+
run: |
101+
if [ "${{ inputs.latest }}" = "true" ]; then
102+
echo "SERVICE_TAGS=ghcr.io/${{ env.REPO_FULL_NAME }}/service:${{ env.NEW_VERSION }},ghcr.io/${{ env.REPO_FULL_NAME }}/service:latest" >> $GITHUB_ENV
103+
else
104+
echo "SERVICE_TAGS=ghcr.io/${{ env.REPO_FULL_NAME }}/service:${{ env.NEW_VERSION }}" >> $GITHUB_ENV
105+
fi
106+
env:
107+
NEW_VERSION: ${{ env.NEW_VERSION }}
108+
REPO_NAME: ${{ env.REPO_NAME }}
109+
REPO_FULL_NAME: ${{ env.REPO_FULL_NAME }}
110+
111+
- name: Log in to the Container registry
112+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
113+
with:
48114
registry: 'ghcr.io'
49-
context: ./service/
50-
is_branch_protected: true
115+
username: ${{ github.actor }}
116+
password: ${{ secrets.ACTION_TOKEN }}
117+
env:
118+
REGISTRY: 'ghcr.io'
119+
120+
- name: Build and push Docker image
121+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
122+
with:
123+
context: '.'
124+
file: './service/Dockerfile'
125+
push: true
126+
tags: ${{ env.SERVICE_TAGS }}
127+
env:
128+
TAGS: ${{ env.SERVICE_TAGS }}
51129

52130
build-app:
53131
runs-on: ubuntu-latest
54-
permissions:
55-
contents: write
56-
packages: write
57-
132+
needs: pre-build
133+
if: ${{ inputs.build_docker_image == 'true' }}
58134
steps:
59-
- name: Build docker
60-
uses: Libertech-FR/lt-actions/release@main
135+
- name: Define app tags
136+
shell: bash
137+
id: define_tags
138+
run: |
139+
if [ "${{ inputs.latest }}" = "true" ]; then
140+
echo "APP_TAGS=ghcr.io/${{ env.REPO_FULL_NAME }}/app:${{ env.NEW_VERSION }},ghcr.io/${{ env.REPO_FULL_NAME }}/app:latest" >> $GITHUB_ENV
141+
else
142+
echo "APP_TAGS=ghcr.io/${{ env.REPO_FULL_NAME }}/app:${{ env.NEW_VERSION }}" >> $GITHUB_ENV
143+
fi
144+
env:
145+
NEW_VERSION: ${{ env.NEW_VERSION }}
146+
REPO_NAME: ${{ env.REPO_NAME }}
147+
REPO_FULL_NAME: ${{ env.REPO_FULL_NAME }}
148+
149+
- name: Log in to the Container registry
150+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
61151
with:
62-
version_increment: ${{ github.event.inputs.version_increment }}
63-
build_docker_image: ${{ github.event.inputs.build_docker_image }}
64-
latest: ${{ github.event.inputs.latest }}
65-
repository: ${{ github.repository }}
66-
username: ${{ github.actor }}
67-
password: ${{ secrets.GITHUB_TOKEN }}
68-
github_token: ${{ secrets.ACTION_TOKEN }}
69-
# Optional parameters, thoses are default values :
70152
registry: 'ghcr.io'
71-
context: ./app/
72-
is_branch_protected: true
153+
username: ${{ github.actor }}
154+
password: ${{ secrets.ACTION_TOKEN }}
155+
env:
156+
REGISTRY: 'ghcr.io'
157+
158+
- name: Build and push Docker image
159+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
160+
with:
161+
context: '.'
162+
file: './app/Dockerfile'
163+
push: true
164+
tags: ${{ env.APP_TAGS }}
165+
env:
166+
tags: ${{ env.APP_TAGS }}
167+
# runs-on: ubuntu-latest
168+
# permissions:
169+
# contents: write
170+
# packages: write
171+
# actions: write
172+
# pull-requests: write
173+
# checks: write
174+
175+
# steps:
176+
# - name: Build docker
177+
# uses: Libertech-FR/lt-actions/release@main
178+
# with:
179+
# version_increment: ${{ github.event.inputs.version_increment }}
180+
# build_docker_image: ${{ github.event.inputs.build_docker_image }}
181+
# latest: ${{ github.event.inputs.latest }}
182+
# repository: ${{ github.repository }}
183+
# username: ${{ github.actor }}
184+
# password: ${{ secrets.GITHUB_TOKEN }}
185+
# github_token: ${{ secrets.ACTION_TOKEN }}
186+
# # Optional parameters, thoses are default values :
187+
# registry: 'ghcr.io'
188+
# context: ./service/
189+
# is_branch_protected: true
190+
191+
# build-app:
192+
# runs-on: ubuntu-latest
193+
# permissions:
194+
# contents: write
195+
# packages: write
196+
197+
# steps:
198+
# - name: Build docker
199+
# uses: Libertech-FR/lt-actions/release@main
200+
# with:
201+
# version_increment: ${{ github.event.inputs.version_increment }}
202+
# build_docker_image: ${{ github.event.inputs.build_docker_image }}
203+
# latest: ${{ github.event.inputs.latest }}
204+
# repository: ${{ github.repository }}
205+
# username: ${{ github.actor }}
206+
# password: ${{ secrets.GITHUB_TOKEN }}
207+
# github_token: ${{ secrets.ACTION_TOKEN }}
208+
# # Optional parameters, thoses are default values :
209+
# registry: 'ghcr.io'
210+
# context: ./app/
211+
# is_branch_protected: true

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,10 @@ populate-db: ## Populate database
7272
docker run --rm --network dev -v $(CURDIR)/populate:/app -v $(CURDIR)/service/.dev-token.json:/app/.dev-token.json seeding_from_data
7373

7474
populate-from-gaiasys: ## Populate database
75-
docker run --rm --network dev -v $(CURDIR)/populate:/app -v $(CURDIR)/service/.dev-token.json:/app/.dev-token.json seeding_from_gaiasys
75+
docker run --rm --network dev -v $(CURDIR)/populate:/app -v $(CURDIR)/service/.dev-token.json:/app/.dev-token.json seeding_from_gaiasys
76+
77+
build-app:
78+
docker build -t teaket-app -f ./app/Dockerfile .
79+
80+
build-service:
81+
docker build -t teaket-service -f ./service/Dockerfile .

app/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ RUN jq -s '.[0] * .[1]' /tmp/root-package.json /tmp/app-package.json > /tmp/merg
3131

3232
COPY /tmp/merged-package.json /usr/src/app/package.json
3333

34-
RUN yarn install \
34+
RUN yarn workspace @libertech-fr/teaket_app install \
3535
--prefer-offline \
3636
--frozen-lockfile \
3737
--non-interactive \
@@ -42,4 +42,4 @@ RUN yarn install \
4242

4343
EXPOSE 3000
4444

45-
CMD ["yarn", "start:prod"]
45+
CMD ["yarn", "workspace", "@libertech-fr/teaket_app", "start:prod"]

service/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ RUN jq -s '.[0] * .[1]' /tmp/root-package.json /tmp/service-package.json > /tmp/
1414

1515
COPY /tmp/merged-package.json /usr/src/app/package.json
1616

17-
RUN apk add git && yarn install \
17+
RUN apk add git && yarn workspace @libertech-fr/teaket_service install \
1818
--prefer-offline \
1919
--frozen-lockfile \
2020
--non-interactive \
2121
--production=false
2222

23-
RUN yarn run build
23+
RUN yarn workspace @libertech-fr/teaket_service run build
2424

2525
FROM node:18.14.0-alpine AS production
2626

@@ -52,9 +52,9 @@ RUN yarn install \
5252

5353
#COPY . .
5454

55-
COPY --from=builder /usr/src/app/dist ./dist
56-
COPY views ./views
55+
COPY --from=builder /usr/src/app/service/dist ./dist
56+
COPY ./service/views ./views
5757

5858
EXPOSE 2100
5959

60-
CMD ["yarn", "start:prod"]
60+
CMD ["yarn", "workspace", "@libertech-fr/teaket_service", "start:prod"]

0 commit comments

Comments
 (0)