From 8dcd98e2be160d18ba7bc1af680876a6b60069d2 Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 22 Mar 2024 12:07:45 -0400 Subject: [PATCH] Adding workflows for each docker build --- .circleci/config.yml | 109 ------------------ .github/workflows/build_php_docker_image.yml | 46 ++++++++ .../build_port_drayage_docker_image.yml | 46 ++++++++ .github/workflows/pull_request.yml | 12 +- tools/port-drayage-webservice/Dockerfile | 4 +- 5 files changed, 97 insertions(+), 120 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/build_php_docker_image.yml create mode 100644 .github/workflows/build_port_drayage_docker_image.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 083450ea6..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,109 +0,0 @@ -version: 2.1 - -# Copyright (C) 2019-2020 LEIDOS. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -# - -# Configuration file for Circle CI -# CI will report failure if any executed command returns and error status -# Operations performed are as follows -# Build source code -# Run unit tests for C++ -# Run static code analyzer for SourceCloud -# Upload test results -# Every run command should start with source ${INIT_ENV} to ensure all default dependencies are available -jobs: - arm_build_push : - machine: - # see https://circleci.com/docs/using-arm/ for versions - image: ubuntu-2004:current - resource_class: arm.medium - steps: - - checkout - - run: - name: Docker Build - # Run MYSQL image and build v2xhub docker image - command: | - docker build -t v2xhubarm:ci-build . - docker build -f docker/Dockerfile-php -t php_arm:ci-build . - cd ./tools/port-drayage-webservice/ - docker build -f Dockerfile-arm -t port-drayage-webservice_arm:ci-build . - if [ -n "$CIRCLE_PR_NUMBER" ]; then - circleci-agent step halt - fi - - run: - name: Docker Push - # Push v2xhub docker image to usdotfhwaops dockerhub - command: | - if [ "$CIRCLE_BRANCH" = "develop" ]; then - DOCKER_TAG="latest" - else - DOCKER_TAG=${CIRCLE_BRANCH/\//-} - fi - docker tag v2xhubarm:ci-build usdotfhwaops/v2xhubarm:${DOCKER_TAG} - docker tag php_arm:ci-build usdotfhwaops/php_arm:${DOCKER_TAG} - docker tag port-drayage-webservice_arm:ci-build usdotfhwaops/port-drayage-webservice_arm:${DOCKER_TAG} - echo "$DOCKERHUB_PASSWORD" | docker login --username $DOCKERHUB_USERNAME --password-stdin - docker push usdotfhwaops/v2xhubarm:${DOCKER_TAG} - docker push usdotfhwaops/php_arm:${DOCKER_TAG} - docker push usdotfhwaops/port-drayage-webservice_arm:${DOCKER_TAG} - automated_release : - machine: - image: ubuntu-2004:202201-02 - steps: - - run: - name: Docker Pull Release - # Pull all built images associated with github tag - command: | - docker pull usdotfhwaops/php:master - docker pull usdotfhwaops/port-drayage-webservice:master - docker pull usdotfhwaops/v2xhubamd:master - docker pull usdotfhwaops/php_arm:master - docker pull usdotfhwaops/port-drayage-webservice_arm:master - docker pull usdotfhwaops/v2xhubarm:master - - run: - name: Docker Tag Release - # Tag all pulled images with github tag name - command: | - docker tag usdotfhwaops/php:master usdotfhwaops/php:${CIRCLE_TAG} - docker tag usdotfhwaops/port-drayage-webservice:master usdotfhwaops/port-drayage-webservice:${CIRCLE_TAG} - docker tag usdotfhwaops/v2xhubamd:master usdotfhwaops/v2xhubamd:${CIRCLE_TAG} - docker tag usdotfhwaops/php_arm:master usdotfhwaops/php_arm:${CIRCLE_TAG} - docker tag usdotfhwaops/port-drayage-webservice_arm:master usdotfhwaops/port-drayage-webservice_arm:${CIRCLE_TAG} - docker tag usdotfhwaops/v2xhubarm:master usdotfhwaops/v2xhubarm:${CIRCLE_TAG} - - run: - name: Docker Push Release Tag - # Push all tagged images - command: | - echo "$DOCKERHUB_PASSWORD" | docker login --username $DOCKERHUB_USERNAME --password-stdin - docker push usdotfhwaops/php:${CIRCLE_TAG} - docker push usdotfhwaops/port-drayage-webservice:${CIRCLE_TAG} - docker push usdotfhwaops/v2xhubamd:${CIRCLE_TAG} - docker push usdotfhwaops/php_arm:${CIRCLE_TAG} - docker push usdotfhwaops/port-drayage-webservice_arm:${CIRCLE_TAG} - docker push usdotfhwaops/v2xhubarm:${CIRCLE_TAG} -workflows: - version: 2 - build: - jobs: - - arm_build_push: - filters: - tags: - only: /^[\.0-9]*$/ - - automated_release: - filters: - tags: - only: /^[\.0-9]*$/ - branches: - ignore: /.*/ diff --git a/.github/workflows/build_php_docker_image.yml b/.github/workflows/build_php_docker_image.yml new file mode 100644 index 000000000..d074e2333 --- /dev/null +++ b/.github/workflows/build_php_docker_image.yml @@ -0,0 +1,46 @@ +name: Build Port Drayage Web App Docker Image +on: + push: + branches: + - develop + - master + - 'release/**' + - vh-1278-update-to-github-actions +jobs: + v2xhub-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: usdotfhwaops/port_drayage_webservice + tags: | + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + - name: Build and push + uses: docker/build-push-action@v4 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: tools/port-drayage-webservice/ + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + BUILD_ARCHITECTURE=${{ matrix.architecture }} + UBUNTU_CODENAME=${{ matrix.ubuntu-codename }} diff --git a/.github/workflows/build_port_drayage_docker_image.yml b/.github/workflows/build_port_drayage_docker_image.yml new file mode 100644 index 000000000..639c6afb6 --- /dev/null +++ b/.github/workflows/build_port_drayage_docker_image.yml @@ -0,0 +1,46 @@ +name: Build V2X-Hub Docker Image +on: + push: + branches: + - develop + - master + - 'release/**' + - vh-1278-update-to-github-actions +jobs: + v2xhub-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: usdotfhwaops/v2xhub + tags: | + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + - name: Build and push + uses: docker/build-push-action@v4 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: . + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + BUILD_ARCHITECTURE=${{ matrix.architecture }} + UBUNTU_CODENAME=${{ matrix.ubuntu-codename }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 8c9bea2c2..d5bced161 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -5,15 +5,6 @@ on: types: [opened, synchronize, reopened] jobs: docker-image-builds: - strategy: - matrix: - include: - - architecture: x64 - ubuntu-codename: jammy - target: x64-version - - architecture: arm64 - ubuntu-codename: jammy - target: cross-compile-version runs-on: ubuntu-latest steps: - name: Checkout @@ -38,6 +29,7 @@ jobs: uses: docker/build-push-action@v4 with: file: Dockerfile + platforms: linux/amd64,linux/arm64 build-args: | BUILD_ARCHITECTURE=${{ matrix.architecture }} UBUNTU_CODENAME=${{ matrix.ubuntu-codename }} @@ -45,6 +37,7 @@ jobs: uses: docker/build-push-action@v4 with: file: docker/Dockerfile-php + platforms: linux/amd64,linux/arm64 build-args: | BUILD_ARCHITECTURE=${{ matrix.architecture }} UBUNTU_CODENAME=${{ matrix.ubuntu-codename }} @@ -52,6 +45,7 @@ jobs: uses: docker/build-push-action@v4 with: context: tools/port-drayage-webservice + platforms: linux/amd64,linux/arm64 build-args: | BUILD_ARCHITECTURE=${{ matrix.architecture }} UBUNTU_CODENAME=${{ matrix.ubuntu-codename }} diff --git a/tools/port-drayage-webservice/Dockerfile b/tools/port-drayage-webservice/Dockerfile index 1f27a0549..27e8e0402 100644 --- a/tools/port-drayage-webservice/Dockerfile +++ b/tools/port-drayage-webservice/Dockerfile @@ -1,10 +1,10 @@ -FROM amd64/maven:3.8-jdk-11-slim AS maven_build +FROM maven:3.8-jdk-11-slim AS maven_build RUN mkdir /home/port-drayage-webservice COPY src/ /home/port-drayage-webservice/src/ COPY pom.xml /home/port-drayage-webservice/ WORKDIR /home/port-drayage-webservice/ RUN mvn clean install -FROM amd64/alpine:latest +FROM alpine:latest RUN mkdir /home/port-drayage-webservice/ RUN apk add openjdk11-jre --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community COPY --from=maven_build /home/port-drayage-webservice/target/port-drayage-webservice-0.0.1-SNAPSHOT.jar /home/port-drayage-webservice/