Skip to content

Commit b766f16

Browse files
committed
[chore] - (CI): Use services in dockerbuild #885
1 parent 6b5b4f6 commit b766f16

File tree

2 files changed

+131
-139
lines changed

2 files changed

+131
-139
lines changed

.github/workflows/dockerbuild-ci.yml

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,36 @@ jobs:
9292
contents: read
9393
packages: write
9494
pull-requests: write
95+
services:
96+
postgres:
97+
image: postgres:17.2
98+
env:
99+
POSTGRES_USER: portal
100+
POSTGRES_PASSWORD: portal-password
101+
POSTGRES_DB: test_database
102+
PGDATA: /data/postgres
103+
options: >-
104+
--health-cmd "pg_isready -d test_database"
105+
--health-interval 10s
106+
--health-timeout 5s
107+
--health-retries 10
108+
ports:
109+
- 5432:5432
110+
elasticsearch:
111+
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.3
112+
env:
113+
discovery.type: single-node
114+
xpack.ml.enabled: false
115+
xpack.security.enabled: false
116+
ES_JAVA_OPTS: "-Xms256m -Xmx256m"
117+
options: >-
118+
--health-cmd "curl --silent --fail localhost:9200/_cluster/health?wait_for_status=yellow&timeout=5s || exit 1"
119+
--health-interval 10s
120+
--health-timeout 5s
121+
--health-retries 10
122+
ports:
123+
- 9200:9200
124+
95125
steps:
96126
- name: Checkout repository
97127
uses: actions/checkout@v4
@@ -112,10 +142,37 @@ jobs:
112142
run: |
113143
mkdir -p ctrf
114144
export IMAGE_TAGS="${{ needs.build-images-tests.outputs.docker-tags }}" \
115-
TEAMS_WEBHOOK_E2E="${{ secrets.TEAMS_WEBHOOK_E2E }}" \
116-
GITHUB_PR_TITLE="${{ github.event.pull_request.title }}" \
117-
GITHUB_PR_NUMBER="${{ github.event.pull_request.number }}" \
118-
GITHUB_RUN_ID="${{ github.run_id }}"
145+
export TEAMS_WEBHOOK_E2E="${{ secrets.TEAMS_WEBHOOK_E2E }}" \
146+
export GITHUB_PR_TITLE="${{ github.event.pull_request.title }}" \
147+
export GITHUB_PR_NUMBER="${{ github.event.pull_request.number }}" \
148+
export GITHUB_RUN_ID="${{ github.run_id }}"
149+
echo "Starting portal-api to check logs..."
150+
docker run --rm \
151+
--network host \
152+
-e PORT=4001 \
153+
-e DATABASE_HOST=localhost \
154+
-e DATABASE_PORT=5432 \
155+
-e DATABASE_USER=portal \
156+
-e DATABASE_BASE=test_database \
157+
-e DATABASE_PASSWORD=portal-password \
158+
159+
-e ADMIN_PASSWORD=admin \
160+
-e DATA_SEEDING=true \
161+
-e MINIO_BUCKET_NAME=xtmhubbucket \
162+
-e MINIO_ENDPOINT=localhost \
163+
-e MINIO_PORT=9000 \
164+
-e MINIO_ACCESS_KEY=portal \
165+
-e MINIO_SECRET_KEY=changeme \
166+
-e MINIO_USE_SSL=false \
167+
-e NODE_ENV=development \
168+
-e VITEST_MODE=true \
169+
-e START_DEV_SERVER=true \
170+
-e ELASTIC_HOST=localhost \
171+
-e ELASTIC_PORT=9200 \
172+
-e BASE_URL_FRONT=http://localhost:3000 \
173+
filigran/portal-api:${IMAGE_TAGS} || {
174+
echo "Portal API failed to start. This is expected for debugging."
175+
}
119176
docker compose -f ./xtm-hub-dev/docker-compose-ci.yml run portal-e2e-tests || TEST_EXIT_CODE=$?
120177
CONTAINER_ID=$(docker ps -a --filter "name=portal-e2e-tests-run" --format "{{.ID}}" | head -1)
121178
docker cp $CONTAINER_ID:/app/apps/portal-e2e-tests/ctrf/. ./ctrf/

xtm-hub-dev/docker-compose-ci.yml

Lines changed: 70 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -6,106 +6,87 @@ services:
66
options:
77
max-size: "10m"
88
max-file: "3"
9-
build:
10-
context: ../
11-
dockerfile: apps/portal-front/Dockerfile
12-
cache_from:
13-
- type=registry,ref=filigran/portal-front:cache-${IMAGE_TAGS}
14-
- type=registry,ref=filigran/portal-front:main
15-
- type=registry,ref=filigran/portal-front:development
16-
depends_on:
17-
portal-api:
18-
condition: service_healthy
9+
image: filigran/portal-front:${IMAGE_TAGS}
10+
extra_hosts:
11+
- "host.docker.internal:host-gateway"
1912
healthcheck:
20-
test: ["CMD", "wget", "-qO-", "http://portal-front:3000/health"]
13+
test: ["CMD", "wget", "-qO-", "http://localhost:3002/health"]
2114
interval: 10s
2215
timeout: 5s
2316
retries: 10
24-
environment:
25-
- SERVER_HTTP_API=http://portal-api:4001
26-
27-
portal-front-test:
28-
container_name: portal-front-test
29-
logging:
30-
driver: "json-file"
31-
options:
32-
max-size: "10m"
33-
max-file: "3"
34-
build:
35-
context: ../
36-
dockerfile: apps/portal-front/test.Dockerfile
37-
cache_from:
38-
- type=registry,ref=filigran/portal-front:cache-${IMAGE_TAGS}
39-
- type=registry,ref=filigran/portal-front:main
40-
- type=registry,ref=filigran/portal-front:development
41-
environment:
42-
- SERVER_HTTP_API=http://portal-api:4001
43-
volumes:
44-
- "./coverage:/app/apps/portal-front/coverage"
45-
portal-api-test:
46-
container_name: portal-api-test
47-
logging:
48-
driver: "json-file"
49-
options:
50-
max-size: "10m"
51-
max-file: "3"
52-
build:
53-
context: ../
54-
dockerfile: apps/portal-api/test.Dockerfile
55-
cache_from:
56-
- type=registry,ref=filigran/portal-api:cache-${IMAGE_TAGS}
57-
- type=registry,ref=filigran/portal-api:main
58-
- type=registry,ref=filigran/portal-api:development
5917
depends_on:
60-
portal-postgres:
61-
condition: service_healthy
62-
portal-minio:
18+
portal-api:
6319
condition: service_healthy
6420
environment:
65-
- DATABASE_HOST=portal-postgres
66-
- DATABASE_PORT=5432
67-
- DATABASE_USER=portal
68-
- DATABASE_BASE=postgres
69-
- DATABASE_PASSWORD=portal-password
70-
71-
- ADMIN_PASSWORD=admin
72-
- NODE_ENV=development
73-
- MINIO_BUCKET_NAME=xtmhubbucket
74-
- MINIO_ENDPOINT=portal-minio
75-
- MINIO_PORT=9000
76-
- MINIO_ACCESS_KEY=minio
77-
- MINIO_SECRET_KEY=password
78-
- MINIO_USE_SSL=false
79-
volumes:
80-
- "./coverage:/app/apps/portal-api/coverage"
21+
- PORT=3002
22+
- SERVER_HTTP_API=http://localhost:4002
23+
#
24+
# portal-front-test:
25+
# container_name: portal-front-test
26+
# logging:
27+
# driver: "json-file"
28+
# options:
29+
# max-size: "10m"
30+
# max-file: "3"
31+
# build:
32+
# context: ../
33+
# dockerfile: apps/portal-front/test.Dockerfile
34+
# cache_from:
35+
# - type=registry,ref=filigran/portal-front:cache-${IMAGE_TAGS}
36+
# - type=registry,ref=filigran/portal-front:main
37+
# - type=registry,ref=filigran/portal-front:development
38+
# environment:
39+
# - SERVER_HTTP_API=http://portal-api:4001
40+
# volumes:
41+
# - "./coverage:/app/apps/portal-front/coverage"
42+
# portal-api-test:
43+
# container_name: portal-api-test
44+
# logging:
45+
# driver: "json-file"
46+
# options:
47+
# max-size: "10m"
48+
# max-file: "3"
49+
# build:
50+
# context: ../
51+
# dockerfile: apps/portal-api/test.Dockerfile
52+
# cache_from:
53+
# - type=registry,ref=filigran/portal-api:cache-${IMAGE_TAGS}
54+
# - type=registry,ref=filigran/portal-api:main
55+
# - type=registry,ref=filigran/portal-api:development
56+
# environment:
57+
# - DATABASE_HOST=postgres
58+
# - DATABASE_PORT=5432
59+
# - DATABASE_USER=portal
60+
# - DATABASE_BASE=postgres
61+
# - DATABASE_PASSWORD=portal-password
62+
63+
# - ADMIN_PASSWORD=admin
64+
# - NODE_ENV=development
65+
# - MINIO_BUCKET_NAME=xtmhubbucket
66+
# - MINIO_ENDPOINT=minio
67+
# - MINIO_PORT=9000
68+
# - MINIO_ACCESS_KEY=minio
69+
# - MINIO_SECRET_KEY=password
70+
# - MINIO_USE_SSL=false
71+
# volumes:
72+
# - "./coverage:/app/apps/portal-api/coverage"
8173
portal-api:
8274
container_name: portal-api
8375
logging:
8476
driver: "json-file"
8577
options:
8678
max-size: "10m"
8779
max-file: "3"
88-
build:
89-
context: ../
90-
dockerfile: apps/portal-api/Dockerfile
91-
cache_from:
92-
- type=registry,ref=filigran/portal-api:cache-${IMAGE_TAGS}
93-
- type=registry,ref=filigran/portal-api:main
94-
- type=registry,ref=filigran/portal-api:development
80+
image: filigran/portal-api:${IMAGE_TAGS}
81+
network_mode: "host"
9582
healthcheck:
96-
test: ["CMD", "wget", "-qO-", "http://portal-api:4001/health"]
83+
test: ["CMD", "wget", "-qO-", "http://localhost:4002/health"]
9784
interval: 10s
9885
timeout: 5s
9986
retries: 10
100-
depends_on:
101-
portal-postgres:
102-
condition: service_healthy
103-
portal-minio:
104-
condition: service_healthy
105-
portal-elasticsearch:
106-
condition: service_healthy
10787
environment:
108-
- DATABASE_HOST=portal-postgres
88+
- PORT=4002
89+
- DATABASE_HOST=localhost
10990
- DATABASE_PORT=5432
11091
- DATABASE_USER=portal
11192
- DATABASE_BASE=test_database
@@ -114,56 +95,17 @@ services:
11495
- ADMIN_PASSWORD=admin
11596
- DATA_SEEDING=true
11697
- MINIO_BUCKET_NAME=xtmhubbucket
117-
- MINIO_ENDPOINT=portal-minio
98+
- MINIO_ENDPOINT=minio
11899
- MINIO_PORT=9000
119100
- MINIO_ACCESS_KEY=portal
120101
- MINIO_SECRET_KEY=changeme
121102
- MINIO_USE_SSL=false
122103
- NODE_ENV=development
123104
- VITEST_MODE=true
124105
- START_DEV_SERVER=true
125-
- ELASTIC_HOST=portal-elasticsearch
106+
- ELASTIC_HOST=localhost
126107
- ELASTIC_PORT=9200
127-
- BASE_URL_FRONT=http://portal-front:3000
128-
129-
portal-postgres:
130-
container_name: portal-postgres
131-
logging:
132-
driver: "json-file"
133-
options:
134-
max-size: "10m"
135-
max-file: "3"
136-
image: postgres:17.2
137-
environment:
138-
- POSTGRES_USER=portal
139-
- POSTGRES_PASSWORD=portal-password
140-
- POSTGRES_DB=test_database
141-
- PGDATA=/data/postgres
142-
healthcheck:
143-
test: ["CMD-SHELL", "pg_isready", "-d", "test_database"]
144-
interval: 10s
145-
timeout: 5s
146-
retries: 10
147-
148-
portal-elasticsearch:
149-
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.3
150-
container_name: portal-elasticsearch
151-
logging:
152-
driver: "json-file"
153-
options:
154-
max-size: "10m"
155-
max-file: "3"
156-
environment:
157-
- discovery.type=single-node
158-
- xpack.ml.enabled=false
159-
- xpack.security.enabled=false
160-
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
161-
healthcheck:
162-
test: [ "CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health?wait_for_status=yellow&timeout=5s || exit 1" ]
163-
interval: 10s
164-
timeout: 5s
165-
retries: 10
166-
108+
- BASE_URL_FRONT=http://portal-front:3002
167109

168110
portal-minio:
169111
container_name: portal-minio
@@ -189,25 +131,18 @@ services:
189131
options:
190132
max-size: "10m"
191133
max-file: "3"
192-
build:
193-
context: ../
194-
dockerfile: apps/portal-e2e-tests/Dockerfile
195-
cache_from:
196-
- type=registry,ref=filigran/portal-e2e-tests:cache-${IMAGE_TAGS}
197-
- type=registry,ref=filigran/portal-e2e-tests:main
198-
- type=registry,ref=filigran/portal-e2e-tests:development
134+
image: filigran/portal-e2e-tests:${IMAGE_TAGS}
135+
network_mode: "host"
199136
depends_on:
200137
portal-front:
201138
condition: service_healthy
202139
portal-api:
203140
condition: service_healthy
204-
portal-minio:
205-
condition: service_healthy
206141
environment:
207-
- E2E_BASE_URL=http://portal-front:3000
208-
- E2E_API_URL=http://portal-api:4001
142+
- E2E_BASE_URL=http://portal-front:3002
143+
- E2E_API_URL=http://portal-api:4002
209144
- POSTGRES_USER=portal
210-
- DATABASE_HOST=portal-postgres
145+
- DATABASE_HOST=localhost
211146
- POSTGRES_DB=test_database
212147
- POSTGRES_PASSWORD=portal-password
213148
- DATABASE_PORT=5432

0 commit comments

Comments
 (0)