Skip to content

Commit

Permalink
GH workflow for build and push java docker image (#2)
Browse files Browse the repository at this point in the history
* change Dockerfile to build .war and add simple build docker workflow

(cherry picked from commit 914a6ac)
  • Loading branch information
frnandu committed Nov 8, 2024
1 parent 94b7020 commit 7e6df5a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build-and-push-java-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build Docker

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGENAME: ${{ github.event.repository.name }}
TAG: ${{ github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Docker build
uses: mr-smithers-excellent/docker-build-push@v6
id: build
with:
directory: java
image: ${{ env.IMAGENAME }}
dockerfile: java/Dockerfile
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
18 changes: 13 additions & 5 deletions java/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
FROM gradle:jdk17-jammy as builder

WORKDIR /build
COPY . ./
RUN gradle wrapper --gradle-version 8.1.1
RUN ./gradlew build -x test

##########################################################################
# Use official Tomcat base image
FROM tomcat:jre17

# Copy WAR file
COPY app/build/libs/vss-1.0.war /usr/local/tomcat/webapps/vss.war
COPY --from=builder /build/app/build/libs/vss-1.0.war /usr/local/tomcat/webapps/vss.war

# All the below are defaults.
# Pass real values as env variables.
ENV vss.jdbc.url="jdbc:postgresql://postgres:5432/postgres"
ENV vss.jdbc.username=postgres
ENV vss.jdbc.password=YOU_MUST_CHANGE_THIS_PASSWORD
ENV vss.jwt.pubkey="-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq3t7q3HXhyTWS0nWnY+YIYqEwh/Z/Jtwk0DgkqxF455gdzVlSyLyz5NQfXua1jW437/SMEcbHLWcwjxcowj1jvh9blGpvx+xPNH72J5ruDzrh5fhoq2XC7zNt1UVcjkMIlddP4pwK4fV5FrxOWvmxst3Ngp6ShNg5H0yiMTDBF+QqFhRlVqnO4IrIKczxd/VxCXSKJvKjM357n0PVD1KYFT3FJ5fN+d7Fdko16NbfQDDPsfQchfLAF2Tn/r4KZFzCovCQAt7cKDLHl87TvoHVZ4QBGHDIk/w1cig/gERtTqHECVg+wVctWfx6lb+9YG/4/9UgTQpDxAWVaFVd49CwQIDAQAB-----END PUBLIC KEY-----"
#ENV vss.jdbc.url="jdbc:postgresql://postgres:5432/postgres"
#ENV vss.jdbc.username=postgres
#ENV vss.jdbc.password=YOU_MUST_CHANGE_THIS_PASSWORD
#ENV vss.jwt.pubkey="-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq3t7q3HXhyTWS0nWnY+YIYqEwh/Z/Jtwk0DgkqxF455gdzVlSyLyz5NQfXua1jW437/SMEcbHLWcwjxcowj1jvh9blGpvx+xPNH72J5ruDzrh5fhoq2XC7zNt1UVcjkMIlddP4pwK4fV5FrxOWvmxst3Ngp6ShNg5H0yiMTDBF+QqFhRlVqnO4IrIKczxd/VxCXSKJvKjM357n0PVD1KYFT3FJ5fN+d7Fdko16NbfQDDPsfQchfLAF2Tn/r4KZFzCovCQAt7cKDLHl87TvoHVZ4QBGHDIk/w1cig/gERtTqHECVg+wVctWfx6lb+9YG/4/9UgTQpDxAWVaFVd49CwQIDAQAB-----END PUBLIC KEY-----"

EXPOSE 8080
CMD ["catalina.sh", "run"]

0 comments on commit 7e6df5a

Please sign in to comment.