Skip to content

Commit

Permalink
Add initial jib setup
Browse files Browse the repository at this point in the history
  • Loading branch information
optionsome committed Jul 30, 2024
1 parent 77dc9df commit 11a1360
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 10 deletions.
34 changes: 24 additions & 10 deletions .github/workflows/dev-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,32 @@ on:
push:
branches:
- dev-1.x
pull_request:
branches:
- dev-1.x
- jib-refactor-otp1
jobs:
docker-push:
if: github.ref == 'refs/heads/dev-1.x'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build docker image from dev-1.x and push it
run: ./.github/workflows/scripts/build_and_push_dev.sh
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: 8
distribution: adopt
cache: maven
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Build container image with Jib, push to Dockerhub
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_AUTH: ${{ secrets.DOCKER_AUTH }}
CONTAINER_REPO: docker.io/hsldevcom/opentripplanner:jib-testing-v1
CONTAINER_REGISTRY_USER: ${{ secrets.DOCKER_USER }}
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_AUTH }}
run: |
otp_version="jib-testing-v1"
commit_hash=`git rev-parse --short "$GITHUB_SHA"`
date_time=`date +"%Y-%m-%dT%H-%M-%S"`
docker_tag_long="$otp_version-$date_time-$commit_hash"
mvn --batch-mode -P prettierSkip compile com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=$docker_tag_long
48 changes: 48 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,54 @@
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.3</version>
<configuration>
<container>
<mainClass>org.opentripplanner.standalone.OTPMain</mainClass>
<entrypoint>/docker-entrypoint.sh</entrypoint>
<volumes>
<volume>
/var/opentripplanner/
</volume>
</volumes>
<ports>
<port>8080</port>
<port>8081</port>
</ports>
</container>
<from>
<image>openjdk:8u121-jre</image>
<platforms>
<platform>
<architecture>amd64</architecture>
<os>linux</os>
</platform>
</platforms>
</from>
<to>
<image>${env.CONTAINER_REPO}</image>
<auth>
<username>${env.CONTAINER_REGISTRY_USER}</username>
<password>${env.CONTAINER_REGISTRY_PASSWORD}</password>
</auth>
</to>
<extraDirectories>
<permissions>
<permission>
<file>/docker-entrypoint.sh</file>
<mode>755</mode>
</permission>
<permission>
<file>/var/opentripplanner/</file>
<mode>755</mode>
</permission>
</permissions>
</extraDirectories>
</configuration>
</plugin>

<!-- There used to be a dependency-plugin:copy-dependencies plugin entry
here, but the shade-plugin will explode the dependencies even if they aren't
Expand Down
3 changes: 3 additions & 0 deletions src/main/jib/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

java $JAVA_OPTS -cp @/app/jib-classpath-file @/app/jib-main-class-file /var/opentripplanner/ $@

0 comments on commit 11a1360

Please sign in to comment.