Skip to content

Commit

Permalink
Added GH action for building & pushing the Docker image, but there ar…
Browse files Browse the repository at this point in the history
…e issues during the compile time (migration related). Fixed dockerfile
  • Loading branch information
xBlaz3kx committed Dec 13, 2024
1 parent e8fa945 commit dadb7b2
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 3 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "Build & Push Docker Image"

on:
pull_request:
types: [ opened, synchronize ]
paths-ignore:
- '*.md'
branches:
- master
push:
paths-ignore:
- '*.md'
branches:
- master

jobs:
build:
name: Build a Docker image
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
xblaz3kx/steve
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=true
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: go-build-cache
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./k8s/docker/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
16 changes: 13 additions & 3 deletions k8s/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM eclipse-temurin:17-jdk
MAINTAINER daynnnnn
FROM eclipse-temurin:17-jdk as base
LABEL maintainer="daynnnnn"

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

Expand All @@ -9,11 +9,16 @@ ARG DB_PASSWORD
ARG DB_DATABASE
ARG DB_PORT

FROM base as build

WORKDIR /code

ADD /src /code/src
ADD /website /code/website
ADD /pom.xml /code/pom.xml
ADD /mvnw /code/mvnw
ADD /.mvn /code/.mvn


RUN sed -i 's|${db.ip}|${env.DB_HOST}|g' pom.xml
RUN sed -i 's|${db.port}|${env.DB_PORT}|g' pom.xml
Expand All @@ -23,5 +28,10 @@ RUN sed -i 's|${db.schema}|${env.DB_DATABASE}|g' pom.xml

RUN ./mvnw clean package -Pkubernetes -Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"

CMD java -jar target/steve.jar
FROM base
LABEL maintainer="daynnnnn"

COPY --from=build /code/target/steve.jar steve.jar
COPY --from=build /code/target/libs libs

CMD java -jar steve.jar

0 comments on commit dadb7b2

Please sign in to comment.