diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 37ba240a..5f196ca9 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -82,7 +82,7 @@ jobs: - name: Create Release Variables run: | - export RELEASE_VERSION="${{vars.RELEASE_VERSION_PREFIX}}.${{github.run_number}}" + export RELEASE_VERSION="${{vars.RELEASE_VERSION_PREFIX}}.${{ github.event.client_payload.run_number }} echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV export RELEASE_TAG="v${RELEASE_VERSION}" echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV @@ -103,7 +103,7 @@ jobs: repo: context.repo.repo, tag_name: process.env.RELEASE_TAG, body: require('fs').readFileSync('${{ github.workspace }}/release/release-body.md', 'utf8'), - target_commitish: '${{ github.ref_name }}' + target_commitish: '${{ github.event.client_payload.ref_name }}' }); const files = diff --git a/.github/workflows/deploy-eks.yml b/.github/workflows/disabled/deploy-eks.yml similarity index 100% rename from .github/workflows/deploy-eks.yml rename to .github/workflows/disabled/deploy-eks.yml diff --git a/.github/workflows/disabled/test-runtime.yml b/.github/workflows/disabled/test-runtime.yml new file mode 100644 index 00000000..6fa9ddec --- /dev/null +++ b/.github/workflows/disabled/test-runtime.yml @@ -0,0 +1,70 @@ +# +# run the executable and make an authenticated call in each of the platforms: +# +# Windows +# Ubuntu +# MacOS +# Docker + +name: Test Runtime + +on: + push: + branches: [ "nam20485" ] + pull_request: + branches: [ "development", "main", "release", "nam20485" ] + +permissions: + contents: read + +env: + ARTIFACTS_DIR: ${{ github.workspace }}/artifacts + ARTIFACTS_DIR_WIN: ${{ github.workspace }}\artifacts + +jobs: + build: + name: Test Runtime Executables + runs-on: ${{ matrix.os }} + permissions: + contents: write + checks: write + + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + matrix: + include: + # Windows x64 Release + - os: windows-2022 + preset: x64-release + # Linux x64 Release + - os: ubuntu-22.04 + preset: linux-release + # MacOS x64 Release + - os: macos-12 + preset: macos-release + # Linux mingw x64 Release + # - os: ubuntu-22.04 + # preset: linux-mingw-w64-release + # # Linux Python Release + # - os: ubuntu-22.04 + # preset: python-linux-release + + steps: + + - name: Harden Runner + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + # add problem matchers by compiler + - name: Add Problem Matchers + uses: ammaraskar/msvc-problem-matcher@1ebcb382869bfdc2cc645e8a2a43b6d319ea1cc0 # master + if: matrix.os == 'windows-2022' + - name: Add Problem Matchers + uses: ammaraskar/gcc-problem-matcher@0f9c86f9e693db67dacf53986e1674de5f2e5f28 # master + if: matrix.os != 'windows-2022' \ No newline at end of file diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 4067538d..6ffb0f1e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -68,17 +68,41 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create CURRENT_DATETIME Environment Variable + run: | + echo "CURRENT_DATETIME=$(date +"%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV + + - name: Echo CURRENT_DATETIME Environment Variable + env: + CURRENT_DATETIME: ${{ env.CURRENT_DATETIME }} + run: echo ${{ env.CURRENT_DATETIME }} + # Extract metadata (tags, labels) for Docker # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 + env: + DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index + CURRENT_DATETIME: ${{ env.CURRENT_DATETIME }} with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=pr type=ref,event=branch,suffix=-${{github.run_number}} - type=ref,event=branch,suffix=-latest + type=ref,event=branch,suffix=-latest + annotations: | + org.opencontainers.image.source=https://github.com/nam20485/OdbDesign + org.opencontainers.image.description=A free open source cross-platform C++ library for parsing ODB++ Design archives and accessing their data. Exposed via a REST API and packaged inside of a Docker image. The OdbDesign Docker image runs the OdbDesign Server REST API server executable listening on port 8888. + org.opencontainers.image.licenses=MIT + org.opencontainers.image.authors=https://github.com/nam20485 + org.opencontainers.image.url=https://nam20485.github.io/OdbDesign + org.opencontainers.image.documentation=https://github.com/nam20485/OdbDesign?tab=readme-ov-file + org.opencontainers.image.version=${{ github.ref_name }}-${{github.run_number}} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.created=${{ env.CURRENT_DATETIME }} + org.opencontainers.image.title=OdbDesign Server # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action @@ -92,12 +116,16 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + #platforms: linux/amd64 file: Dockerfile + annotations: ${{ steps.meta.outputs.annotations }} build-args: | OWNER=nam20485 GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} VCPKG_BINARY_SOURCES=clear;nuget,GitHub,readwrite - + # ODBDESIGN_SERVER_REQUEST_USERNAME=${{ secrets.ODBDESIGN_SERVER_REQUEST_USERNAME }} + # ODBDESIGN_SERVER_REQUEST_PASSWORD=${{ secrets.ODBDESIGN_SERVER_REQUEST_PASSWORD }} + # Sign the resulting Docker image digest except on PRs. # This will only write to the public Rekor transparency log when the Docker # repository is public to avoid leaking data. If you would like to publish @@ -115,4 +143,9 @@ jobs: with: repository: ${{ github.repository }} event-type: trigger_deploy_release_event - client-payload: '{"ref_name": "${{ github.ref_name }}", "dispatch_id": "${{ secrets.DISPATCH_ID }}"}' + client-payload: | + '{ + "ref_name": "${{ github.ref_name }}", + "run_number": "${{ github.run_number }}", + "dispatch_id": "${{ secrets.DISPATCH_ID }}" + }' diff --git a/.gitignore b/.gitignore index 0bc7f5f5..4770b091 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ OdbDesignServer/db.sqlite3 OdbDesignServer/PyOdbDesignLib/_PyOdbDesignLib.pyd /TEST_DATA.zip deploy/kubeconfig +Dockerfile.commentedOut diff --git a/CMakePresets.json b/CMakePresets.json index c651ef7a..57085208 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -42,7 +42,8 @@ "displayName": "Python x64 Debug", "inherits": "x64-debug", "cacheVariables": { - "PYTHON_MODULE_BUILD": true + "PYTHON_MODULE_BUILD": true, + "CMAKE_POSITION_INDENPENDENT_CODE": true } }, { @@ -58,7 +59,8 @@ "displayName": "Python x64 Release", "inherits": "x64-release", "cacheVariables": { - "PYTHON_MODULE_BUILD": true + "PYTHON_MODULE_BUILD": true, + "CMAKE_POSITION_INDENPENDENT_CODE": true } }, { diff --git a/Dockerfile b/Dockerfile index c74844b8..3290020b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bookworm-20240211@sha256:4482958b4461ff7d9fabc24b3a9ab1e9a2c85ece07b2db1840c7cbc01d053e90 AS build +FROM --platform=$BUILDPLATFORM debian:bookworm-20240211-slim@sha256:d02c76d82364cedca16ba3ed6f9102406fa9fa8833076a609cabf14270f43dfc AS build ARG OWNER=nam20485 ARG GITHUB_TOKEN="PASSWORD" @@ -66,11 +66,13 @@ RUN cmake --build --preset linux-release # RUN cmake --build --preset linux-debug # much smaller runtime image -FROM debian:bookworm-20240211-slim@sha256:d02c76d82364cedca16ba3ed6f9102406fa9fa8833076a609cabf14270f43dfc AS run -LABEL org.opencontainers.image.source=https://github.com/nam20485/OdbDesign -LABEL org.opencontainers.image.authors=https://github.com/nam20485 -LABEL org.opencontainers.image.description="The OdbDesign Docker image runs the OdbDesignServer REST API server executable, listening on port 8888." -LABEL org.opencontainers.image.licenses=MIT +FROM --platform=$BUILDPLATFORM debian:bookworm-20240211-slim@sha256:d02c76d82364cedca16ba3ed6f9102406fa9fa8833076a609cabf14270f43dfc AS run +# ARG ODBDESIGN_SERVER_REQUEST_USERNAME="" +# ARG ODBDESIGN_SERVER_REQUEST_PASSWORD="" +LABEL org.opencontainers.image.source=https://github.com/nam20485/OdbDesign \ + org.opencontainers.image.authors=https://github.com/nam20485 \ + org.opencontainers.image.description="A free open source cross-platform C++ library for parsing ODB++ Design archives and accessing their data. Exposed via a REST API and packaged inside of a Docker image. The OdbDesign Docker image runs the OdbDesignServer REST API server executable, listening on port 8888." \ + org.opencontainers.image.licenses=MIT EXPOSE 8888 RUN mkdir --parents /OdbDesign/bin @@ -92,5 +94,7 @@ RUN mkdir ./designs # run ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/OdbDesign/bin +# ENV ODBDESIGN_SERVER_REQUEST_USERNAME=${ODBDESIGN_SERVER_REQUEST_USERNAME} +# ENV ODBDESIGN_SERVER_REQUEST_PASSWORD=${ODBDESIGN_SERVER_REQUEST_PASSWORD} RUN chmod +x ./OdbDesignServer -ENTRYPOINT [ "./OdbDesignServer" ] +ENTRYPOINT [ "./OdbDesignServer", "--designs-dir", "./designs", "--templates-dir", "./templates" ] diff --git a/compose.yml b/compose.yml new file mode 100644 index 00000000..0d1165e5 --- /dev/null +++ b/compose.yml @@ -0,0 +1,34 @@ +name: odbdesignserver-swaggerui + +services: + + odbdesign-server: + ## enable for passing in branch name as an environment variable + #environment: + # - BRANCH=nam20485 + #image: ghcr.io/nam20485/odbdesign:${BRANCH}-latest + image: ghcr.io/nam20485/odbdesign:nam20485-latest + ## enable for local build via the Dockerfile (and disable "image:" key above) + # build: + # context: . + # dockerfile: Dockerfile + container_name: odbdesign-server + ports: + - 8888:8888 + environment: + - ODBDESIGN_SERVER_REQUEST_USERNAME + - ODBDESIGN_SERVER_REQUEST_PASSWORD + + + swagger-ui: + ## enable for passing in branch name as an environment variable + # environment: + # - BRANCH=nam20485 + # image: ghcr.io/nam20485/odbdesignserver-swaggerui:${BRANCH}-latest + image: ghcr.io/nam20485/odbdesignserver-swaggerui:nam20485-latest + container_name: swagger-ui + depends_on: + - odbdesign-server + ports: + - 8080:8080 + \ No newline at end of file