Skip to content

Commit 12f7dff

Browse files
authored
Standarize Docker builds across projects (#2256)
* Use Docker BuildX to build image, consistently with other SchemaCrawler Docker images * Update GitHub Actions workflows * Add DEBUG * Remove Docker ignore file, since we point the context directly * debug * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Docker image * Revert to old file * Update Docker image * Make early release consistent with SchemaCrawler-AI * Use Docker BuildX to build image, consistently with other SchemaCrawler Docker images * Update GitHub Actions workflows * Add DEBUG * Remove Docker ignore file, since we point the context directly * debug * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Docker image * Revert to old file * Update Docker image * Make early release consistent with SchemaCrawler-AI * Standardize Docker builds * Change base image to Eclipse Temurin * Use Docker BuildX to build image, consistently with other SchemaCrawler Docker images * Update GitHub Actions workflows * Add DEBUG * Remove Docker ignore file, since we point the context directly * debug * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Docker image * Revert to old file * Update Docker image * Make early release consistent with SchemaCrawler-AI * Update Dockerfile * Update Dockerfile * Update Docker image * Revert to old file * Update Docker image * Make early release consistent with SchemaCrawler-AI * Standardize Docker builds * Change base image to Eclipse Temurin
1 parent 978134d commit 12f7dff

File tree

8 files changed

+270
-251
lines changed

8 files changed

+270
-251
lines changed

.github/workflows/early-release.yml

Lines changed: 103 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
env:
14+
DOCKER_IMAGE_NAME: schemacrawler/schemacrawler
15+
DOCKER_IMAGE_TAG: early-access-release
16+
DOCKERFILE_PATH: ./schemacrawler-distrib/Dockerfile
17+
DOCKER_CONTEXT_PATH: ./schemacrawler-distrib/target/_expanded-distribution/
18+
1319
jobs:
1420
build:
1521
name: Create Early Access Release
@@ -19,7 +25,7 @@ jobs:
1925
github.event_name == 'workflow_dispatch'
2026
runs-on: ubuntu-latest
2127
permissions:
22-
id-token: write # Required for OIDC authentication
28+
id-token: write # Required for OIDC authentication
2329
contents: write # Required to create a new tag
2430
steps:
2531

@@ -47,45 +53,30 @@ jobs:
4753
shell: bash
4854
run: |
4955
# Build
56+
# ... and install (for later phase of Docker image tests)
5057
mvn \
5158
--no-transfer-progress \
5259
--batch-mode \
5360
-Ddistrib \
54-
-Dskiptests \
5561
clean install
56-
57-
# CREATE GITHUB RELEASE AND ADD ASSETS
58-
- id: install-gitsign
59-
name: Install gitsign for commit signing
60-
# See https://github.com/chainguard-dev/actions/blob/main/setup-gitsign/action.yml
61-
uses: chainguard-dev/actions/setup-gitsign@18e5e3427cf9d6bcfbefe60dca48e40292f000c5
62-
- id: move-tag
63-
name: Move early-access-release tag
64-
env:
65-
GITSIGN_CONNECTOR_ID: "https://github.com/login/oauth"
66-
GITSIGN_TOKEN_PROVIDER: "github-actions"
62+
- id: show-distrib
63+
name: Show distribution directory
6764
shell: bash
6865
run: |
69-
# Move early-access-release tag
70-
# Set up user
71-
git config user.name "Sualeh Fatehi"
72-
git config user.email "[email protected]"
73-
# Confirm gitsign is installed
74-
gitsign --version
75-
# Move tag
76-
git tag -d early-access-release || true
77-
git push --delete origin early-access-release || true
78-
git tag -a early-access-release -m "SchemaCrawler Early Access Release"
79-
git push --follow-tags origin early-access-release
80-
git show --no-patch early-access-release
66+
# Show distribution directory
67+
echo "Show distribution directory"
68+
ls -1R ./schemacrawler-distrib/target/_expanded-distribution
69+
70+
71+
# CREATE GITHUB RELEASE
8172
- id: create-release
8273
name: Create GitHub early access release
8374
uses: softprops/action-gh-release@v2
8475
with:
8576
target_commitish: ${{ github.sha }}
86-
tag_name: early-access-release
77+
tag_name: ${{ env.DOCKER_IMAGE_TAG }}
8778
token: ${{ secrets.GITHUB_TOKEN }}
88-
name: early-access-release
79+
name: ${{ env.DOCKER_IMAGE_TAG }}
8980
draft: false
9081
prerelease: true
9182
body: |
@@ -98,6 +89,31 @@ jobs:
9889
./schemacrawler-distrib/target/schemacrawler-17.6.0-bin.zip.SHA-512
9990
overwrite_files: true
10091

92+
# MOVE GITHUB TAG
93+
- id: install-gitsign
94+
name: Install gitsign for commit signing
95+
# See https://github.com/chainguard-dev/actions/blob/main/setup-gitsign/action.yml
96+
uses: chainguard-dev/actions/setup-gitsign@18e5e3427cf9d6bcfbefe60dca48e40292f000c5
97+
- id: move-tag
98+
name: Move early-access-release tag
99+
env:
100+
GITSIGN_CONNECTOR_ID: "https://github.com/login/oauth"
101+
GITSIGN_TOKEN_PROVIDER: "github-actions"
102+
shell: bash
103+
run: |
104+
# Move early-access-release tag
105+
# Set up user
106+
git config user.name "Sualeh Fatehi"
107+
git config user.email "[email protected]"
108+
# Confirm gitsign is installed
109+
gitsign --version
110+
# Move tag
111+
git tag -d ${{ env.DOCKER_IMAGE_TAG }} || true
112+
git push --delete origin ${{ env.DOCKER_IMAGE_TAG }} || true
113+
git tag -a ${{ env.DOCKER_IMAGE_TAG }} -m "SchemaCrawler AI Early Access Release"
114+
git push --follow-tags origin ${{ env.DOCKER_IMAGE_TAG }}
115+
git show --no-patch ${{ env.DOCKER_IMAGE_TAG }}
116+
101117
# BUILD AND PUBLISH DOCKER IMAGE
102118
- id: setup-qemu
103119
name: Setup QEMU
@@ -114,17 +130,72 @@ jobs:
114130
username: ${{ secrets.DOCKER_USERNAME }}
115131
password: ${{ secrets.DOCKER_PASSWORD }}
116132

133+
- id: validate-build-configuration
134+
name: Validate build configuration
135+
uses: docker/build-push-action@v6
136+
with:
137+
call: check
138+
file: ${{ env.DOCKERFILE_PATH }}
139+
context: ${{ env.DOCKER_CONTEXT_PATH }}
140+
load: false
141+
push: false
142+
143+
- id: meta
144+
name: Set up Docker metadata
145+
uses: docker/metadata-action@v5
146+
with:
147+
images: |
148+
${{ env.DOCKER_IMAGE_NAME }}
149+
tags: |
150+
type=raw,value=${{ env.DOCKER_IMAGE_TAG }},priority=1200
151+
labels: |
152+
maintainer=Sualeh Fatehi <[email protected]>
153+
org.opencontainers.image.authors=Sualeh Fatehi <[email protected]>
154+
org.opencontainers.image.vendor=SchemaCrawler
155+
org.opencontainers.image.licenses=(EPL-2.0)
156+
org.opencontainers.image.url=https://www.schemacrawler.com/
157+
org.opencontainers.image.documentation=https://github.com/schemacrawler/SchemaCrawler-Usage
158+
117159
- id: build-docker-image
118-
name: Build and Push Docker Image
160+
name: Build Docker image locally
161+
uses: docker/build-push-action@v6
162+
with:
163+
call: build
164+
file: ${{ env.DOCKERFILE_PATH }}
165+
context: ${{ env.DOCKER_CONTEXT_PATH }}
166+
cache-from: type=gha
167+
cache-to: type=gha,mode=max
168+
# Build just for runner platform
169+
platforms: linux/amd64
170+
tags: ${{ steps.meta.outputs.tags }}
171+
labels: ${{ steps.meta.outputs.labels }}
172+
annotations: ${{ steps.meta.outputs.annotations }}
173+
load: true
174+
push: false
175+
176+
- id: test-docker-image
177+
name: Test Docker image build
178+
shell: bash
179+
run: |
180+
# Run the Testcontainers integration test
181+
# This will pull the Docker image, start it, and verify the health endpoint
182+
183+
- id: push-docker-image
184+
name: Build and push Docker image
119185
uses: docker/build-push-action@v6
120186
with:
121-
file: ./schemacrawler-docker/Dockerfile
122-
context: ./schemacrawler-distrib/target/_expanded-distribution
187+
call: build
188+
file: ${{ env.DOCKERFILE_PATH }}
189+
context: ${{ env.DOCKER_CONTEXT_PATH }}
190+
cache-from: type=gha
191+
cache-to: type=gha,mode=max
123192
platforms: |-
124193
linux/amd64
125194
linux/arm64
126-
tags: |-
127-
schemacrawler/schemacrawler:early-access-release
195+
tags: ${{ steps.meta.outputs.tags }}
196+
labels: ${{ steps.meta.outputs.labels }}
197+
annotations: ${{ steps.meta.outputs.annotations }}
128198
sbom: true
129199
provenance: true
200+
load: false
130201
push: true

.github/workflows/release.yml

Lines changed: 102 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
env:
14+
DOCKER_IMAGE_NAME: schemacrawler/schemacrawler
15+
DOCKER_IMAGE_TAG: latest
16+
DOCKERFILE_PATH: ./schemacrawler-distrib/Dockerfile
17+
DOCKER_CONTEXT_PATH: ./schemacrawler-distrib/target/_expanded-distribution/
18+
1319
jobs:
1420
release:
1521
name: Create Release
1622
runs-on: ubuntu-latest
1723
permissions:
24+
id-token: write # Required for OIDC authentication
1825
contents: write # Required to create a new tag
1926
steps:
2027

@@ -49,50 +56,20 @@ jobs:
4956
shell: bash
5057
run: |
5158
# Build
59+
# ... and install (for later phase of Docker image tests)
5260
mvn \
5361
--no-transfer-progress \
5462
--batch-mode \
5563
-Ddistrib \
5664
clean install
57-
- id: show-distribiution
65+
- id: show-distrib
5866
name: Show distribution directory
5967
shell: bash
6068
run: |
6169
# Show distribution directory
6270
echo "Show distribution directory"
6371
ls -1R ./schemacrawler-distrib/target/_expanded-distribution
6472
65-
# BUILD AND PUBLISH DOCKER IMAGE
66-
- id: setup-qemu
67-
name: Setup QEMU
68-
uses: docker/setup-qemu-action@v3
69-
70-
- id: setup-buildx
71-
name: Setup Docker Buildx
72-
uses: docker/setup-buildx-action@v3
73-
74-
- id: docker-login
75-
name: Log into Docker Hub
76-
uses: docker/login-action@v3
77-
with:
78-
username: ${{ secrets.DOCKER_USERNAME }}
79-
password: ${{ secrets.DOCKER_PASSWORD }}
80-
81-
- id: build-docker-image
82-
name: Build and Push Docker Image
83-
uses: docker/build-push-action@v6
84-
with:
85-
file: ./schemacrawler-docker/Dockerfile
86-
context: ./schemacrawler-distrib/target/_expanded-distribution
87-
platforms: |-
88-
linux/amd64
89-
linux/arm64
90-
tags: |-
91-
schemacrawler/schemacrawler:v17.6.0
92-
schemacrawler/schemacrawler:latest
93-
sbom: true
94-
provenance: true
95-
push: true
9673
9774
# CREATE GITHUB RELEASE AND ADD ASSETS
9875
- id: upload-artifacts
@@ -105,7 +82,7 @@ jobs:
10582
./schemacrawler-distrib/target/schemacrawler-17.6.0-distribution.zip.SHA-512
10683
./schemacrawler-distrib/target/schemacrawler-17.6.0-bin.zip
10784
./schemacrawler-distrib/target/schemacrawler-17.6.0-bin.zip.SHA-512
108-
retention-days: 1
85+
retention-days: 2
10986
- id: create-release
11087
name: Create GitHub release
11188
uses: softprops/action-gh-release@v2
@@ -124,6 +101,98 @@ jobs:
124101
./schemacrawler-distrib/target/schemacrawler-17.6.0-distribution.zip.SHA-512
125102
./schemacrawler-distrib/target/schemacrawler-17.6.0-bin.zip
126103
./schemacrawler-distrib/target/schemacrawler-17.6.0-bin.zip.SHA-512
104+
overwrite_files: true
105+
106+
# BUILD AND PUBLISH DOCKER IMAGE
107+
- id: setup-qemu
108+
name: Setup QEMU
109+
uses: docker/setup-qemu-action@v3
110+
111+
- id: setup-buildx
112+
name: Setup Docker Buildx
113+
uses: docker/setup-buildx-action@v3
114+
115+
- id: docker-login
116+
name: Log into Docker Hub
117+
uses: docker/login-action@v3
118+
with:
119+
username: ${{ secrets.DOCKER_USERNAME }}
120+
password: ${{ secrets.DOCKER_PASSWORD }}
121+
122+
- id: validate-build-configuration
123+
name: Validate build configuration
124+
uses: docker/build-push-action@v6
125+
with:
126+
call: check
127+
file: ${{ env.DOCKERFILE_PATH }}
128+
context: ${{ env.DOCKER_CONTEXT_PATH }}
129+
load: false
130+
push: false
131+
132+
- id: meta
133+
name: Set up Docker metadata
134+
uses: docker/metadata-action@v5
135+
with:
136+
images: |
137+
${{ env.DOCKER_IMAGE_NAME }}
138+
tags: |
139+
type=raw,value=${{ env.DOCKER_IMAGE_TAG }},priority=1200
140+
type=raw,value={{ tag }},priority=1190
141+
type=semver,pattern=v{{version}},priority=940
142+
type=semver,pattern={{version}},priority=930
143+
type=semver,pattern={{major}}.{{minor}},priority=920
144+
type=semver,pattern={{major}},priority=910
145+
labels: |
146+
maintainer=Sualeh Fatehi <[email protected]>
147+
org.opencontainers.image.authors=Sualeh Fatehi <[email protected]>
148+
org.opencontainers.image.vendor=SchemaCrawler
149+
org.opencontainers.image.licenses=(EPL-2.0)
150+
org.opencontainers.image.url=https://www.schemacrawler.com/
151+
org.opencontainers.image.documentation=https://github.com/schemacrawler/SchemaCrawler-Usage
152+
153+
- id: build-docker-image
154+
name: Build Docker image locally
155+
uses: docker/build-push-action@v6
156+
with:
157+
call: build
158+
file: ${{ env.DOCKERFILE_PATH }}
159+
context: ${{ env.DOCKER_CONTEXT_PATH }}
160+
cache-from: type=gha
161+
cache-to: type=gha,mode=max
162+
# Build just for runner platform
163+
platforms: linux/amd64
164+
tags: ${{ steps.meta.outputs.tags }}
165+
labels: ${{ steps.meta.outputs.labels }}
166+
annotations: ${{ steps.meta.outputs.annotations }}
167+
load: true
168+
push: false
169+
170+
- id: test-docker-image
171+
name: Test Docker image build
172+
shell: bash
173+
run: |
174+
# Run the Testcontainers integration test
175+
# This will pull the Docker image, start it, and verify the health endpoint
176+
177+
- id: push-docker-image
178+
name: Build and push Docker image
179+
uses: docker/build-push-action@v6
180+
with:
181+
call: build
182+
file: ${{ env.DOCKERFILE_PATH }}
183+
context: ${{ env.DOCKER_CONTEXT_PATH }}
184+
cache-from: type=gha
185+
cache-to: type=gha,mode=max
186+
platforms: |-
187+
linux/amd64
188+
linux/arm64
189+
tags: ${{ steps.meta.outputs.tags }}
190+
labels: ${{ steps.meta.outputs.labels }}
191+
annotations: ${{ steps.meta.outputs.annotations }}
192+
sbom: true
193+
provenance: true
194+
load: false
195+
push: true
127196

128197
# PUBLISH TO CENTRAL REPOSITORY
129198
- id: publish-to-central

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<module>schemacrawler-sqlite</module>
3737
<module>schemacrawler-sqlserver</module>
3838
<module>schemacrawler-offline</module>
39-
<!-- Additional modules -->
39+
<!-- Additional modules -->
4040
<module>schemacrawler-docs</module>
4141
<module>schemacrawler-library-bom</module>
4242
</modules>
@@ -51,7 +51,6 @@
5151
</activation>
5252
<modules>
5353
<module>schemacrawler-distrib</module>
54-
<module>schemacrawler-docker</module>
5554
<module>schemacrawler-website</module>
5655
</modules>
5756
</profile>

0 commit comments

Comments
 (0)