Skip to content

Add log4j into docker image (#174) #282

Add log4j into docker image (#174)

Add log4j into docker image (#174) #282

Workflow file for this run

name: Docker
on:
push:
branches:
- 'master' # produce latest image
- '[0-9]+.X-stable' # produce stable-latest image
tags:
- 'vfrinx-[0-9]+.[0-9]+.[0-9]' # produce release image (6.0.0)
- 'vfrinx-[0-9]+.[0-9]+.[0-9]-stable' # produce stable release image (5.1.0)
env:
# TODO: Change variable to your image's name.
IMAGE_NAME: frinx/conductor-server
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
build-image-v2:
runs-on: ubuntu-latest
# Dependency for swagger export
services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive # fetch submodules
- name: Log into docker hub
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
- name: Build image
run: docker build . --file docker/server/Dockerfile --tag $IMAGE_NAME:latest --build-arg git_commit=$(git rev-parse HEAD)
# Start conductor for swagger export with network to postgres service
- name: Run conductor image
run: docker run -d --network "$(docker network ls --filter type=custom --format '{{ .Name }}')" --publish 8080:8080 $IMAGE_NAME:latest
#### Set tags based on source type ####
- name: Set tag for latest image
if: github.ref_type == 'branch' && startsWith(github.ref, 'refs/heads/master')
run: |
echo "IMAGE_TAG=$(echo 'latest')" >> "$GITHUB_ENV"
- name: Set tag for stable-latest image
if: github.ref_type == 'branch' && endsWith(github.ref, '-stable')
run: |
echo "IMAGE_TAG=$(echo 'stable-latest')" >> "$GITHUB_ENV"
- name: Set tag for stable-release image
if: github.ref_type == 'tag' && endsWith(github.ref, '-stable')
run: |
echo "IMAGE_TAG=$(echo $GITHUB_REF | cut -d / -f 3 | sed -e 's/^vfrinx-//' | sed -e 's/-stable//')" >> "$GITHUB_ENV"
- name: Set tag for release image
if: ${{ github.ref_type == 'tag' && !endsWith(github.ref, '-stable') }}
run: |
echo "IMAGE_TAG=$(echo $GITHUB_REF | cut -d / -f 3 | sed -e 's/^vfrinx-//')" >> "$GITHUB_ENV"
# Tag and publish docker image
- name: Push stable-release image
run: |
docker tag $IMAGE_NAME:latest $IMAGE_NAME:${IMAGE_TAG}
docker push $IMAGE_NAME:${IMAGE_TAG}
#### OpenAPI publish ####
- name: Check conductor health
uses: nick-fields/retry@v2
with:
timeout_seconds: 10
max_attempts: 10
retry_on: error
command: |
curl -X 'GET' 'http://localhost:8080/health' -H 'accept: */*' | grep '"healthy":true'
- name: Get conductor openapi spec
run: |
curl http://localhost:8080/v3/api-docs -H "x-auth-user-groups: network-admin" -H "x-tenant-id: frinx" -H "from: admin" -o openapi.json
- name: Check out swagger_docs branch
uses: actions/checkout@v4
with:
ref: swagger_docs
path: swagger_docs
fetch-depth: 2
token: ${{ secrets.GH_PAT_TOKEN }}
- name: Copy files to swagger_docs
run: |
GIT_HASH=$(git rev-parse --short $GITHUB_SHA)
jq . openapi.json > swagger_docs/${IMAGE_TAG}.json
pushd swagger_docs || exit 1
git config -l --show-scope
git config --global user.email "[email protected]"
git config --global user.name "FRINXrepo"
git add *.json
(git commit -am "Updated swagger for ${GITHUB_REF_NAME}/${GIT_HASH}" && git push) || true
popd