@@ -58,65 +58,148 @@ jobs:
5858
5959 # Publish to PyPI
6060 twine upload dist/*
61+
6162 build-and-push-images :
6263 name : Build and Push Docker Images
6364 runs-on : ubuntu-latest
6465 permissions :
6566 contents : read
6667 packages : write
67-
68+
6869 steps :
6970 - name : Checkout repository
7071 uses : actions/checkout@v4
71-
72+
7273 - name : Set up QEMU
7374 uses : docker/setup-qemu-action@v3
74-
75+
7576 - name : Set up Docker Buildx
7677 uses : docker/setup-buildx-action@v3
7778
7879 - name : Log in to GitHub Container Registry
79- uses : docker/login-action@v3.3.0
80+ uses : docker/login-action@v3
8081 with :
8182 registry : ghcr.io
8283 username : ${{ github.actor }}
8384 password : ${{ secrets.GITHUB_TOKEN }}
84-
85+
8586 - name : Extract metadata for Elasticsearch image
8687 id : meta-es
87- uses : docker/metadata-action@v5.5.1
88+ uses : docker/metadata-action@v5
8889 with :
89- images : ghcr.io/stac-utils /stac-fastapi-es
90+ images : ghcr.io/${{ github.repository_owner }} /stac-fastapi-es
9091 tags : |
9192 type=raw,value=latest
9293 type=ref,event=tag
94+
95+ - name : Build Elasticsearch image
96+ uses : docker/build-push-action@v6
97+ with :
98+ context : .
99+ file : dockerfiles/Dockerfile.ci.es
100+ platforms : linux/amd64
101+ push : false
102+ load : true
103+ tags : stac-fastapi-es:test
104+ cache-from : type=gha
105+ cache-to : type=gha,mode=max
106+
107+ - name : Test Elasticsearch image
108+ run : |
109+ docker run -d --name stac-es \
110+ -e APP_HOST=0.0.0.0 \
111+ -e APP_PORT=8080 \
112+ -e ES_HOST=localhost \
113+ -e ES_PORT=9200 \
114+ stac-fastapi-es:test
93115
94- - name : Build and push Elasticsearch Docker image
95- uses : docker/build-push-action@v6.9.0
116+ timeout=120
117+ while [ $timeout -gt 0 ]; do
118+ if docker inspect stac-es --format='{{.State.Health.Status}}' | grep -q 'healthy'; then
119+ echo "Container is healthy"
120+ break
121+ fi
122+ if [ $timeout -eq 0 ]; then
123+ echo "Health check failed"
124+ docker logs stac-es
125+ docker stop stac-es
126+ docker rm stac-es
127+ exit 1
128+ fi
129+ sleep 5
130+ timeout=$((timeout-5))
131+ done
132+
133+ docker stop stac-es
134+ docker rm stac-es
135+
136+ - name : Push Elasticsearch image
137+ uses : docker/build-push-action@v6
96138 with :
97139 context : .
98- file : dockerfiles/Dockerfile.deploy .es
140+ file : dockerfiles/Dockerfile.ci .es
99141 platforms : linux/amd64,linux/arm64
100142 push : true
101143 tags : ${{ steps.meta-es.outputs.tags }}
102144 labels : ${{ steps.meta-es.outputs.labels }}
103145 cache-from : type=gha
104146 cache-to : type=gha,mode=max
105-
147+
106148 - name : Extract metadata for OpenSearch image
107149 id : meta-os
108- uses : docker/metadata-action@v5.5.1
150+ uses : docker/metadata-action@v5
109151 with :
110- images : ghcr.io/stac-utils /stac-fastapi-os
152+ images : ghcr.io/${{ github.repository_owner }} /stac-fastapi-os
111153 tags : |
112154 type=raw,value=latest
113155 type=ref,event=tag
156+
157+ - name : Build OpenSearch image
158+ uses : docker/build-push-action@v6
159+ with :
160+ context : .
161+ file : dockerfiles/Dockerfile.ci.os
162+ platforms : linux/amd64
163+ push : false
164+ load : true
165+ tags : stac-fastapi-os:test
166+ cache-from : type=gha
167+ cache-to : type=gha,mode=max
168+
169+ - name : Test OpenSearch image
170+ run : |
171+ docker run -d --name stac-os \
172+ -e APP_HOST=0.0.0.0 \
173+ -e APP_PORT=8080 \
174+ -e OS_HOST=localhost \
175+ -e OS_PORT=9200 \
176+ stac-fastapi-os:test
177+
178+ timeout=120
179+ while [ $timeout -gt 0 ]; do
180+ if docker inspect stac-os --format='{{.State.Health.Status}}' | grep -q 'healthy'; then
181+ echo "Container is healthy"
182+ break
183+ fi
184+ if [ $timeout -eq 0 ]; then
185+ echo "Health check failed"
186+ docker logs stac-os
187+ docker stop stac-os
188+ docker rm stac-os
189+ exit 1
190+ fi
191+ sleep 5
192+ timeout=$((timeout-5))
193+ done
114194
115- - name : Build and push OpenSearch Docker image
116- uses : docker/build-push-action@v6.9.0
195+ docker stop stac-os
196+ docker rm stac-os
197+
198+ - name : Push OpenSearch image
199+ uses : docker/build-push-action@v6
117200 with :
118201 context : .
119- file : dockerfiles/Dockerfile.deploy .os
202+ file : dockerfiles/Dockerfile.ci .os
120203 platforms : linux/amd64,linux/arm64
121204 push : true
122205 tags : ${{ steps.meta-os.outputs.tags }}
0 commit comments