@@ -208,7 +208,7 @@ jobs:
208208 echo "authly admin client create --name MyApp --client-type public --redirect-uri http://localhost:3000/callback" >> $GITHUB_STEP_SUMMARY
209209 echo '```' >> $GITHUB_STEP_SUMMARY
210210
211- docker-build-and-push :
211+ docker-build-production :
212212 runs-on : ubuntu-latest
213213 needs : [validate-release, lint-and-test, build-and-publish]
214214 permissions :
@@ -246,7 +246,7 @@ jobs:
246246 type=semver,pattern={{major}},value=${{ needs.validate-release.outputs.version }}
247247 type=raw,value=latest
248248
249- - name : Build and push Docker image
249+ - name : Build and push production Docker image
250250 uses : docker/build-push-action@v6
251251 with :
252252 context : .
@@ -259,12 +259,12 @@ jobs:
259259 cache-from : type=gha
260260 cache-to : type=gha,mode=max
261261
262- - name : Update deployment summary with Docker info
262+ - name : Update deployment summary with production Docker info
263263 run : |
264264 echo "" >> $GITHUB_STEP_SUMMARY
265- echo "### Docker Images" >> $GITHUB_STEP_SUMMARY
265+ echo "### Production Docker Images" >> $GITHUB_STEP_SUMMARY
266266 echo '```bash' >> $GITHUB_STEP_SUMMARY
267- echo "# Pull and run Docker image" >> $GITHUB_STEP_SUMMARY
267+ echo "# Pull and run production Docker image" >> $GITHUB_STEP_SUMMARY
268268 echo "docker pull descoped/authly:${{ needs.validate-release.outputs.version }}" >> $GITHUB_STEP_SUMMARY
269269 echo "docker run -p 8000:8000 descoped/authly:${{ needs.validate-release.outputs.version }}" >> $GITHUB_STEP_SUMMARY
270270 echo "" >> $GITHUB_STEP_SUMMARY
@@ -296,6 +296,48 @@ jobs:
296296 username : ${{ secrets.DOCKERHUB_USERNAME }}
297297 password : ${{ secrets.DOCKERHUB_TOKEN }}
298298
299+ - name : Log in to GitHub Container Registry
300+ uses : docker/login-action@v3
301+ with :
302+ registry : ghcr.io
303+ username : ${{ github.actor }}
304+ password : ${{ secrets.GITHUB_TOKEN }}
305+
306+ - name : Check for existing postgres-builder image
307+ id : check-postgres-builder
308+ run : |
309+ # PostgreSQL version tag - update this when PostgreSQL version changes
310+ # This should match the version in Dockerfile.standalone (line 29)
311+ # When updating, also increment to force a rebuild of the cached image
312+ PG_VERSION="17.2"
313+ PG_TAG="postgres-builder-${PG_VERSION}-alpine3.22"
314+
315+ # Try to pull the postgres-builder image from GitHub packages
316+ if docker pull ghcr.io/descoped/authly-postgres-builder:${PG_TAG} 2>/dev/null; then
317+ echo "✅ Found cached postgres-builder image: ${PG_TAG}"
318+ echo "exists=true" >> $GITHUB_OUTPUT
319+ echo "tag=${PG_TAG}" >> $GITHUB_OUTPUT
320+ else
321+ echo "🔨 Need to build postgres-builder image: ${PG_TAG}"
322+ echo "exists=false" >> $GITHUB_OUTPUT
323+ echo "tag=${PG_TAG}" >> $GITHUB_OUTPUT
324+ fi
325+
326+ - name : Build and push postgres-builder stage if not cached
327+ if : steps.check-postgres-builder.outputs.exists != 'true'
328+ uses : docker/build-push-action@v6
329+ with :
330+ context : .
331+ file : ./Dockerfile.standalone
332+ target : postgres-builder
333+ platforms : linux/amd64,linux/arm64
334+ push : true
335+ tags : |
336+ ghcr.io/descoped/authly-postgres-builder:${{ steps.check-postgres-builder.outputs.tag }}
337+ ghcr.io/descoped/authly-postgres-builder:latest
338+ cache-from : type=gha,scope=postgres-builder
339+ cache-to : type=gha,scope=postgres-builder,mode=max
340+
299341 - name : Extract metadata for standalone image
300342 id : meta-standalone
301343 uses : docker/metadata-action@v5
@@ -317,7 +359,11 @@ jobs:
317359 push : true
318360 tags : ${{ steps.meta-standalone.outputs.tags }}
319361 labels : ${{ steps.meta-standalone.outputs.labels }}
320- cache-from : type=gha,scope=standalone
362+ build-args : |
363+ POSTGRES_BUILDER_IMAGE=ghcr.io/descoped/authly-postgres-builder:${{ steps.check-postgres-builder.outputs.tag }}
364+ cache-from : |
365+ type=gha,scope=standalone
366+ type=registry,ref=ghcr.io/descoped/authly-postgres-builder:${{ steps.check-postgres-builder.outputs.tag }}
321367 cache-to : type=gha,scope=standalone,mode=max
322368
323369 - name : Update deployment summary with standalone Docker info
0 commit comments