From 16d93f19631f382a5f76e92a43790ece0bc6c877 Mon Sep 17 00:00:00 2001 From: dev Date: Mon, 29 Apr 2024 17:23:13 -0400 Subject: [PATCH] Uncouple docker-compose from version --- .github/workflows/build.yml | 106 ------------------ .github/workflows/build_php_docker_image.yml | 48 ++++++++ .../build_port_drayage_docker_image.yml | 48 ++++++++ .../workflows/build_v2xhub_docker_image.yml | 47 ++++++++ .github/workflows/pull_request.yml | 51 +++++++++ .github/workflows/sonar-scanner.yml | 12 +- configuration/amd64/docker-compose.yml | 20 +++- configuration/arm64/docker-compose.yml | 6 +- 8 files changed, 220 insertions(+), 118 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/build_php_docker_image.yml create mode 100644 .github/workflows/build_port_drayage_docker_image.yml create mode 100644 .github/workflows/build_v2xhub_docker_image.yml create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index eed361c5b..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Build Workflows - -on: - pull_request: - push: - -# TODO push to dockerhub with correct tags -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/v2xhubamd - 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 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - php-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/php - 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: - file: docker/Dockerfile-php - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - port-drayage-docker: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - 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 - context: tools/port-drayage-webservice - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/build_php_docker_image.yml b/.github/workflows/build_php_docker_image.yml new file mode 100644 index 000000000..bb9ee7cc1 --- /dev/null +++ b/.github/workflows/build_php_docker_image.yml @@ -0,0 +1,48 @@ +name: Build PHP V2X-Hub Web UI +on: + push: + branches: + - develop + - master + - 'release/**' + # Build all tags not containing a / (https://stackoverflow.com/questions/61891328/trigger-github-action-only-on-new-tags ) + tags: + - '*' +jobs: + v2xhub-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - 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@v5 + with: + images: usdotfhwaops/php + 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@v5 + with: + push: true + platforms: linux/amd64,linux/arm64 + file: ./docker/Dockerfile-php + 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..dd9115995 --- /dev/null +++ b/.github/workflows/build_port_drayage_docker_image.yml @@ -0,0 +1,48 @@ +name: Build Port Drayage Web Service +on: + push: + branches: + - develop + - master + - 'release/**' + # Build all tags not containing a / (https://stackoverflow.com/questions/61891328/trigger-github-action-only-on-new-tags ) + tags: + - '*' +jobs: + v2xhub-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - 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@v5 + 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@v5 + 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_v2xhub_docker_image.yml b/.github/workflows/build_v2xhub_docker_image.yml new file mode 100644 index 000000000..c8ec318d9 --- /dev/null +++ b/.github/workflows/build_v2xhub_docker_image.yml @@ -0,0 +1,47 @@ +name: Build V2X-Hub Docker Image +on: + push: + branches: + - develop + - master + - 'release/**' + # Build all tags not containing a / (https://stackoverflow.com/questions/61891328/trigger-github-action-only-on-new-tags ) + tags: + - '*' +jobs: + v2xhub-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - 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@v5 + 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@v5 + with: + push: true + platforms: linux/amd64,linux/arm64 + 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 new file mode 100644 index 000000000..17d8f1dc6 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,51 @@ +name: Pull Request Workflow + +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + docker-image-builds: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: usdotfhwaops/php + 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: V2X-Hub Docker build + uses: docker/build-push-action@v5 + with: + file: Dockerfile + platforms: linux/amd64,linux/arm64 + build-args: | + BUILD_ARCHITECTURE=${{ matrix.architecture }} + UBUNTU_CODENAME=${{ matrix.ubuntu-codename }} + - name: PHP Docker build + uses: docker/build-push-action@v5 + with: + file: docker/Dockerfile-php + platforms: linux/amd64,linux/arm64 + build-args: | + BUILD_ARCHITECTURE=${{ matrix.architecture }} + UBUNTU_CODENAME=${{ matrix.ubuntu-codename }} + - name: Port Drayage Docker build + uses: docker/build-push-action@v5 + 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/.github/workflows/sonar-scanner.yml b/.github/workflows/sonar-scanner.yml index 6df6b7812..f1acdd7e4 100644 --- a/.github/workflows/sonar-scanner.yml +++ b/.github/workflows/sonar-scanner.yml @@ -1,7 +1,11 @@ on: push: - # run on branches and not PRs due to secrets used branches: + - develop + - master + - "release/*" + pull_request: + types: [opened, synchronize, reopened] name: Sonar Workflow jobs: sonarcloud: @@ -9,13 +13,13 @@ jobs: container: image: ubuntu:jammy-20230126 steps: - - name: Install curl, zip, git, gcovr + - name: Install gcovr run: | apt update export DEBIAN_FRONTEND=noninteractive - apt-get install -y curl zip git gcovr + apt-get install -y gcovr - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 diff --git a/configuration/amd64/docker-compose.yml b/configuration/amd64/docker-compose.yml index 89a1b00a9..9e1cda0cd 100755 --- a/configuration/amd64/docker-compose.yml +++ b/configuration/amd64/docker-compose.yml @@ -20,7 +20,7 @@ services: - mysql-datavolume:/var/lib/mysql php: - image: usdotfhwaops/php:7.6.0 + image: usdotfhwaops/php:${V2XHUB_VERSION:-develop} container_name: php network_mode: host depends_on: @@ -30,7 +30,7 @@ services: tty: true v2xhub: - image: usdotfhwaops/v2xhubamd:7.6.0 + image: usdotfhwaops/v2xhubamd:${V2XHUB_VERSION:-develop} container_name: v2xhub network_mode: host restart: always @@ -38,15 +38,25 @@ services: - db environment: - MYSQL_PASSWORD=/run/secrets/mysql_password - - INFRASTRUCTURE_ID=rsu_ - - INFRASTRUCTURE_NAME= + - SIMULATION_MODE=${SIMULATION_MODE:-false} + - SIMULATION_IP=${SIMULATION_IP:-127.0.0.1} + - SIMULATION_REGISTRATION_PORT=6767 + - LOCAL_IP=${LOCAL_IP:-127.0.0.1} + - TIME_SYNC_TOPIC=time_sync + - TIME_SYNC_PORT=7575 + - SIM_V2X_PORT=5757 + - SIM_INTERACTION_PORT=7576 + - V2X_PORT=8686 + - INFRASTRUCTURE_ID=${INFRASTRUCTURE_ID:-rsu_1234} + - INFRASTRUCTURE_NAME=${INFRASTRUCTURE_NAME:-East Intersection} + - SENSOR_JSON_FILE_PATH=${SENSOR_JSON_FILE_PATH:-/var/www/plugins/MAP/sensors.json} secrets: - mysql_password volumes: - ./logs:/var/log/tmx - ./MAP:/var/www/plugins/MAP port_drayage_webservice: - image: usdotfhwaops/port-drayage-webservice:7.6.0 + image: usdotfhwaops/port-drayage-webservice:${V2XHUB_VERSION:-develop} container_name: port_drayage_webservice network_mode: host secrets: diff --git a/configuration/arm64/docker-compose.yml b/configuration/arm64/docker-compose.yml index 4e378c4c5..a7ffcce50 100644 --- a/configuration/arm64/docker-compose.yml +++ b/configuration/arm64/docker-compose.yml @@ -20,7 +20,7 @@ services: - mysql-datavolume:/var/lib/mysql php: - image: usdotfhwaops/php_arm:7.6.0 + image: usdotfhwaops/php_arm:${V2XHUB_VERSION:-develop} container_name: php network_mode: host depends_on: @@ -30,7 +30,7 @@ services: tty: true v2xhub: - image: usdotfhwaops/v2xhubarm:7.6.0 + image: usdotfhwaops/v2xhubarm:${V2XHUB_VERSION:-develop} container_name: v2xhub network_mode: host restart: always @@ -44,7 +44,7 @@ services: - ./logs:/var/log/tmx - ./MAP:/var/www/plugins/MAP port_drayage_webservice: - image: usdotfhwaops/port-drayage-webservice_arm:7.6.0 + image: usdotfhwaops/port-drayage-webservice_arm:${V2XHUB_VERSION:-develop} container_name: port_drayage_webservice network_mode: host secrets: