diff --git a/.github/workflows/dev-pipeline.yml b/.github/workflows/dev-pipeline.yml index 9bf5d0c24a9..24a2c376764 100644 --- a/.github/workflows/dev-pipeline.yml +++ b/.github/workflows/dev-pipeline.yml @@ -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 diff --git a/.github/workflows/scripts/build_and_push_dev.sh b/.github/workflows/scripts/build_and_push_dev.sh deleted file mode 100755 index 85c0eb6d517..00000000000 --- a/.github/workflows/scripts/build_and_push_dev.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -e - -DOCKER_IMAGE="hsldevcom/opentripplanner" -DOCKER_TAG="latest" - -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 - -# Build image -echo Building OTP -docker build --tag="$DOCKER_IMAGE:builder" -f Dockerfile.builder . -docker run --rm --entrypoint tar "$DOCKER_IMAGE:builder" -c target|tar x -C ./ -docker build --tag="$DOCKER_IMAGE_TAG_LONG" -f Dockerfile . - -docker login -u $DOCKER_USER -p $DOCKER_AUTH -echo "Pushing $DOCKER_TAG image" -docker push $DOCKER_IMAGE_TAG_LONG -docker tag $DOCKER_IMAGE_TAG_LONG $DOCKER_IMAGE_TAG -docker push $DOCKER_IMAGE_TAG - -echo Build completed diff --git a/.github/workflows/scripts/push_prod.sh b/.github/workflows/scripts/push_prod.sh index f2eaacde776..4ae53ebfdc3 100755 --- a/.github/workflows/scripts/push_prod.sh +++ b/.github/workflows/scripts/push_prod.sh @@ -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 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 90ef4c9c7a0..00000000000 --- a/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM openjdk:8u121-jre-alpine -MAINTAINER Reittiopas version: 0.1 - -RUN apk add --update curl bash ttf-dejavu && \ - rm -rf /var/cache/apk/* -VOLUME /opt/opentripplanner/graphs - -ENV OTP_ROOT="/opt/opentripplanner" -ENV ROUTER_DATA_CONTAINER_URL="https://api.digitransit.fi/routing-data/v2/finland" - -WORKDIR ${OTP_ROOT} - -ADD run.sh ${OTP_ROOT}/run.sh -ADD target/*-shaded.jar ${OTP_ROOT}/otp-shaded.jar - -ENV PORT=8080 -EXPOSE ${PORT} -ENV SECURE_PORT=8081 -EXPOSE ${SECURE_PORT} -ENV ROUTER_NAME=finland -ENV JAVA_OPTS="-Xms8G -Xmx8G" - -ENTRYPOINT exec ./run.sh diff --git a/Dockerfile.builder b/Dockerfile.builder deleted file mode 100644 index 9f5cfec10fa..00000000000 --- a/Dockerfile.builder +++ /dev/null @@ -1,15 +0,0 @@ -FROM maven:3-jdk-8 -MAINTAINER Reittiopas version: 0.1 - -RUN apt-get update && apt-get -y install curl - -ENV OTP_ROOT="/opt/opentripplanner" - -WORKDIR ${OTP_ROOT} - -ADD pom.xml ${OTP_ROOT}/pom.xml -ADD src ${OTP_ROOT}/src -add .git ${OTP_ROOT}/.git - -# Build OTP -RUN mvn package diff --git a/pom.xml b/pom.xml index 1cc7c32f1c9..fc60b17b802 100644 --- a/pom.xml +++ b/pom.xml @@ -296,6 +296,54 @@ false + + com.google.cloud.tools + jib-maven-plugin + 3.4.3 + + + org.opentripplanner.standalone.OTPMain + /docker-entrypoint.sh + + + /var/opentripplanner/ + + + + 8080 + 8081 + + + + openjdk:8u121-jre + + + amd64 + linux + + + + + ${env.CONTAINER_REPO} + + ${env.CONTAINER_REGISTRY_USER} + ${env.CONTAINER_REGISTRY_PASSWORD} + + + + + + /docker-entrypoint.sh + 755 + + + /var/opentripplanner/ + 755 + + + + +