Skip to content

Commit 4cddb81

Browse files
committed
Build docker images using github actions
1 parent ac58080 commit 4cddb81

File tree

5 files changed

+59
-11
lines changed

5 files changed

+59
-11
lines changed

.github/workflows/botfest.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ jobs:
4040
runs-on: ubuntu-latest
4141
needs: test
4242
if: github.ref == 'refs/heads/prod'
43+
permissions:
44+
contents: read
45+
packages: write
46+
attestations: write
47+
id-token: write
4348
steps:
4449
- name: Checkout repository
4550
uses: actions/checkout@v4
@@ -50,9 +55,21 @@ jobs:
5055
- name: Build project and generate docker file
5156
run: ./gradlew botfest:createDockerfile
5257

58+
- name: Login to GitHub Container Registry
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ghcr.io
62+
username: ${{ github.repository_owner }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Docker meta
66+
id: meta
67+
uses: docker/metadata-action@v5
68+
5369
- name: Build and push docker image
5470
uses: docker/build-push-action@v6
5571
with:
5672
context: "botfest/build"
5773
push: true
58-
tags: modfest/botfest:latest
74+
tags: ghcr.io/modfest/botfest:latest
75+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/panel.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ jobs:
1717
publish:
1818
runs-on: ubuntu-latest
1919
if: github.ref == 'refs/heads/prod'
20+
permissions:
21+
contents: read
22+
packages: write
23+
attestations: write
24+
id-token: write
2025
steps:
2126
- name: Checkout repository
2227
uses: actions/checkout@v4
@@ -28,10 +33,15 @@ jobs:
2833
username: ${{ github.repository_owner }}
2934
password: ${{ secrets.GITHUB_TOKEN }}
3035

36+
- name: Docker meta
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
3140
- name: Build and push docker image
3241
uses: docker/build-push-action@v6
3342
with:
3443
context: "."
3544
file: "panel/Dockerfile"
3645
push: true
37-
tags: modfest/platform_api:latest
46+
tags: ghcr.io/modfest/panel:latest
47+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/platform_api.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ jobs:
4040
runs-on: ubuntu-latest
4141
needs: test
4242
if: github.ref == 'refs/heads/prod'
43+
permissions:
44+
contents: read
45+
packages: write
46+
attestations: write
47+
id-token: write
4348
steps:
4449
- name: Checkout repository
4550
uses: actions/checkout@v4
@@ -50,9 +55,21 @@ jobs:
5055
- name: Build project and generate docker file
5156
run: ./gradlew platform_api:createDockerfile
5257

58+
- name: Login to GitHub Container Registry
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ghcr.io
62+
username: ${{ github.repository_owner }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Docker meta
66+
id: meta
67+
uses: docker/metadata-action@v5
68+
5369
- name: Build and push docker image
5470
uses: docker/build-push-action@v6
5571
with:
5672
context: "platform_api/build"
5773
push: true
58-
tags: modfest/platform_api:latest
74+
tags: ghcr.io/modfest/platform_api:latest
75+
labels: ${{ steps.meta.outputs.labels }}

panel/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ ENV NODE_ENV=production
4242
RUN addgroup --system --gid 1001 nodejs
4343
RUN adduser --system --uid 1001 nextjs
4444

45-
COPY --from=builder /app/panel/public ./public
46-
4745
# Automatically leverage output traces to reduce image size
4846
# https://nextjs.org/docs/advanced-features/output-file-tracing
4947
COPY --from=builder --chown=nextjs:nodejs /app/panel/.next/standalone ./

platform_api/build.gradle.kts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ tasks.bootRun {
9393
)
9494
}
9595

96-
tasks.createDockerfile { dependsOn("bootBuildImage") }
96+
tasks.createDockerfile { dependsOn("bootJar") }
9797
docker {
9898
generateOnBuild = false
9999

@@ -109,19 +109,25 @@ docker {
109109

110110
runShell("groupadd --system --gid 1001 platform")
111111
runShell("useradd --system --gid 1001 --uid 1001 platform")
112+
runShell("mkdir -p /app")
113+
runShell("chown platform /app")
114+
112115
user("platform")
113116

114117
workdir("/app")
115118

116-
val filename = tasks.bootBuildImage.get().archiveFile.get()
119+
val filename = tasks.bootJar.get().archiveFile.get()
117120
.asFile.relativeTo(dockerfileLocation.parentFile)
118121
copy("$filename", "/app/app.jar")
119122

120-
runShell("mkdir -p /var/lib/platform/data")
123+
runShell("mkdir -p /app/data")
121124

122-
env {
123-
add("SERVER_PORT", "8080")
124-
}
125+
add(object : DockerfileCommand() {
126+
override val keyword: String
127+
get() = "ENV"
128+
129+
override fun toString(): String = "ENV SERVER_PORT=8080 PLATFORM_DATADIR=/app/data"
130+
})
125131

126132
expose(8080)
127133
entryPointExec(

0 commit comments

Comments
 (0)