Skip to content

Commit

Permalink
Merge pull request #383 from HSLdevcom/jib-refactor-otp1
Browse files Browse the repository at this point in the history
DT-6317 Use jib as a docker build tool for otp1
  • Loading branch information
vesameskanen authored Aug 26, 2024
2 parents 77dc9df + dd5aea1 commit c845439
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 182 deletions.
33 changes: 23 additions & 10 deletions .github/workflows/dev-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,31 @@ on:
push:
branches:
- dev-1.x
pull_request:
branches:
- dev-1.x
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:v1
CONTAINER_REGISTRY_USER: ${{ secrets.DOCKER_USER }}
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_AUTH }}
run: |
otp_version="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
25 changes: 0 additions & 25 deletions .github/workflows/scripts/build_and_push_dev.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/scripts/push_prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
set -e

DOCKER_IMAGE="hsldevcom/opentripplanner"
DOCKER_TAG="prod"
DOCKER_TAG="v1-prod"

COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")

DOCKER_TAG_LONG=$DOCKER_TAG-$(date +"%Y-%m-%dT%H.%M.%S")-$COMMIT_HASH
DOCKER_IMAGE_TAG=$DOCKER_IMAGE:$DOCKER_TAG
DOCKER_IMAGE_TAG_LONG=$DOCKER_IMAGE:$DOCKER_TAG_LONG
DOCKER_IMAGE_LATEST=$DOCKER_IMAGE:latest
DOCKER_IMAGE_LATEST=$DOCKER_IMAGE:v1

docker login -u $DOCKER_USER -p $DOCKER_AUTH

Expand Down
23 changes: 0 additions & 23 deletions Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions Dockerfile.builder

This file was deleted.

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
107 changes: 0 additions & 107 deletions run.sh

This file was deleted.

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 $( cat /app/jib-classpath-file ) $( cat /app/jib-main-class-file ) $@

0 comments on commit c845439

Please sign in to comment.