Skip to content

Commit

Permalink
fix: Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
kkweon committed Sep 13, 2021
1 parent 2033e78 commit 7ee2687
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 2 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Release

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: "11"
distribution: "adopt"
- run: gradle build
- run: gradle test

release:
runs-on: ubuntu-latest
needs:
- build
outputs:
# Whether a new release was published (true or false)
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
# Version of the new release. (e.g. 1.3.0)
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
# Major version of the new release. (e.g. 1)
new_release_major_version: ${{ steps.semantic.outputs.new_release_major_version }}
# Minor version of the new release. (e.g. 3)
new_release_minor_version: ${{ steps.semantic.outputs.new_release_minor_version }}
# Patch version of the new release. (e.g. 0)
new_release_patch_version: ${{ steps.semantic.outputs.new_release_patch_version }}
# The distribution channel on which the last release was initially made available (undefined for the default distribution channel).
new_release_channel: ${{ steps.semantic.outputs.new_release_channel }}
# The release notes for the new release.
new_release_notes: ${{ steps.semantic.outputs.new_release_notes }}

steps:
- uses: actions/checkout@v2
- uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
semantic_version: 17
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker:
runs-on: ubuntu-latest

needs:
- release

if: ${{ needs.release.outputs.new_release_published == 'true' }}

steps:
- uses: actions/checkout@v2
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/codingpot/pr12er
tags: |
type=raw,value=${{ needs.release.outputs.new_release_major_version }}
type=raw,value=${{ needs.release.outputs.new_release_major_version }}.${{ needs.release.outputs.new_release_minor_version }}
type=raw,value=${{ needs.release.outputs.new_release_version }}
type=raw,value=latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
10 changes: 10 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
]
}
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:11
FROM openjdk:11 as build

ENV APP_HOME=/codingpot
WORKDIR $APP_HOME
Expand All @@ -12,4 +12,6 @@ RUN ./gradlew resolveDependencies
COPY . $APP_HOME
RUN ./gradlew build

ENTRYPOINT java -jar app/build/libs/app.jar
FROM gcr.io/distroless/java:11
COPY --from=build /codingpot/app/build/libs/app.jar /codingpot/
CMD ["/codingpot/app.jar"]

0 comments on commit 7ee2687

Please sign in to comment.