Skip to content

Commit

Permalink
Wrote build action
Browse files Browse the repository at this point in the history
  • Loading branch information
zachauten committed Sep 24, 2024
1 parent 03c2a4a commit 61a6588
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:23-noble
FROM eclipse-temurin:21-jammy

RUN apt-get update && apt-get -y install \
maven git tree
36 changes: 36 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build OCI image
on: push
jobs:
Build:
runs-on: ubuntu-latest
env:
IMAGE: ghcr.io/${{ github.repository }}
permissions:
attestations: write
contents: read
id-token: write
packages: write

steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.IMAGE }}

- uses: docker/bake-action@v5
id: bake
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
push: true
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# docker build -t spring-app .
# docker run --name spring-app -d -p 8080:8080 spring-app

FROM maven:3.9.8-eclipse-temurin-21 as build
# docker run --name spring-boilerplate -d -p 8080:8080 spring-boilerplate
FROM maven:3.9.8-eclipse-temurin-21 AS build

COPY pom.xml .
RUN --mount=type=cache,target=/root/.m2,rw mvn -B dependency:go-offline
COPY src src
RUN --mount=type=cache,target=/root/.m2,rw mvn -B package

FROM eclipse-temurin:21
FROM eclipse-temurin:21-jammy

WORKDIR /app
COPY --from=build target/*.jar ./app.jar
Expand All @@ -25,4 +23,3 @@ ENTRYPOINT ["java", "-javaagent:/app/opentelemetry-javaagent.jar", "-jar", "app.

EXPOSE 8080
HEALTHCHECK CMD curl -f http://0.0.0.0:8080/health || exit 1

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Spring Boilerplate

## Building
Build using [buildx bake](https://docs.docker.com/build/bake/):

`docker buildx bake` (From the project root)

## Observability

### Commands to test open telemetry locally
Expand Down
7 changes: 7 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target "docker-metadata-action" {}

target "default" {
inherits = ["docker-metadata-action"]
context = "."
dockerfile = "Dockerfile"
}

0 comments on commit 61a6588

Please sign in to comment.