diff --git a/.github/workflows/devel-chart.yaml b/.github/workflows/devel-chart.yaml deleted file mode 100644 index aec0192..0000000 --- a/.github/workflows/devel-chart.yaml +++ /dev/null @@ -1,37 +0,0 @@ -name: Devel - chart - -on: - push: - branches: ['devel'] - -jobs: - release: - # depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions - # see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token - permissions: - contents: write - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Configure Git - run: | - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - - name: Install Helm - uses: azure/setup-helm@v4 - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.6.0 - with: - config: charts/chart-releaser.yaml - mark_as_latest: false - pages_branch: gh-pages - env: - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/devel-image.yaml b/.github/workflows/devel-image.yaml deleted file mode 100644 index 8a607d9..0000000 --- a/.github/workflows/devel-image.yaml +++ /dev/null @@ -1,58 +0,0 @@ -name: Devel - image - -# Configures this workflow to run every time a change is pushed to the branch called `release`. -on: - push: - branches: ['devel'] - -# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. -jobs: - build-and-push-image: - runs-on: ubuntu-latest - # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. - permissions: - contents: read - packages: write - attestations: write - id-token: write - # - steps: - - name: Checkout repository - uses: actions/checkout@v4 - # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. - # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. - # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. - - name: Build and push Docker image - id: push - uses: docker/build-push-action@v6 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)." - - name: Generate artifact attestation - uses: actions/attest-build-provenance@v1 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} - subject-digest: ${{ steps.push.outputs.digest }} - push-to-registry: true diff --git a/.github/workflows/publish-chart.yaml b/.github/workflows/publish-chart.yaml new file mode 100644 index 0000000..a934c69 --- /dev/null +++ b/.github/workflows/publish-chart.yaml @@ -0,0 +1,68 @@ +name: Publish helm chart +run-name: Publish helm chart + +on: + push: + tags: ["chart-*"] + branches: ['main', 'devel'] + paths: ['chart/**'] + +env: + CHART_PATH: chart + UPDATE_DEPS: 'false' + # GitHub Container registry + GHCR_NAME: ${{ github.repository_owner }}/helm + # Docker Hub + # DHUB_NAME: insios-helm + # DHUB_USERNAME: ${{ secrets.INSIOS_DOCKER_USERNAME }} + # DHUB_PASSWORD: ${{ secrets.INSIOS_DOCKER_PASSWORD }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Helm + uses: azure/setup-helm@v4 + + - name: Extract metadata (chart name, tag) + id: meta + run: | + echo "name=$(helm show chart ${{ env.CHART_PATH }} | grep 'name:' | awk '{print $2}')" >> "$GITHUB_OUTPUT" + if [[ "${{ github.ref_type }}" == "tag" ]]; then + echo "tag=$(echo '${{ github.ref_name }}' | awk -F '-' '{print $2}')" >> "$GITHUB_OUTPUT" + else + echo "tag=0.0.0-${{ github.ref_name }}" >> "$GITHUB_OUTPUT" + fi + + - name: Build and push Helm chart to Container registry + uses: appany/helm-oci-chart-releaser@v0.4.2 + with: + path: ${{ env.CHART_PATH }} + update_dependencies: '${{ env.UPDATE_DEPS }}' + name: ${{ steps.meta.outputs.name }} + tag: ${{ steps.meta.outputs.tag }} + registry: ghcr.io + registry_username: ${{ github.actor }} + registry_password: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ env.GHCR_NAME }} + + # - name: Build and push Helm chart to Docker Hub + # uses: appany/helm-oci-chart-releaser@v0.4.2 + # with: + # path: ${{ env.CHART_PATH }} + # update_dependencies: '${{ env.UPDATE_DEPS }}' + # name: ${{ steps.meta.outputs.name }} + # tag: ${{ steps.meta.outputs.tag }} + # registry: registry-1.docker.io + # registry_username: ${{ env.DHUB_USERNAME }} + # registry_password: ${{ env.DHUB_PASSWORD }} + # repository: ${{ env.DHUB_NAME }} diff --git a/.github/workflows/publish-image.yaml b/.github/workflows/publish-image.yaml new file mode 100644 index 0000000..d445689 --- /dev/null +++ b/.github/workflows/publish-image.yaml @@ -0,0 +1,72 @@ +name: Publish docker image +run-name: Publish docker image + +on: + push: + tags: ["app-*"] + branches: ['main', 'devel'] + paths: ['app/**'] + +env: + APP_PATH: app + # GitHub Container registry + GHCR_NAME: ${{ github.repository_owner }}/docker/${{ github.event.repository.name }} + # Docker Hub + DHUB_NAME: insios/${{ github.event.repository.name }} + DHUB_USERNAME: ${{ secrets.INSIOS_DOCKER_USERNAME }} + DHUB_PASSWORD: ${{ secrets.INSIOS_DOCKER_PASSWORD }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ env.DHUB_USERNAME }} + password: ${{ env.DHUB_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ env.GHCR_NAME }} + ${{ env.DHUB_NAME }} + tags: | + type=ref,event=branch + type=match,pattern=app-(\d+.\d+.\d+),group=1 + type=match,pattern=app-(\d+.\d+),group=1 + type=match,pattern=app-(\d+),group=1 + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v6 + with: + context: ${{ APP_PATH }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: ghcr.io/${{ env.GHCR_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/app/.dockerignore b/app/.dockerignore new file mode 100644 index 0000000..9414382 --- /dev/null +++ b/app/.dockerignore @@ -0,0 +1 @@ +Dockerfile diff --git a/Dockerfile b/app/Dockerfile similarity index 98% rename from Dockerfile rename to app/Dockerfile index 4f6cefc..8e71b06 100644 --- a/Dockerfile +++ b/app/Dockerfile @@ -33,7 +33,7 @@ RUN ln -sf $APP_LIB/bin/docker-entrypoint.sh /usr/bin/docker-entrypoint.sh && \ ln -sf /usr/bin/msmtp /usr/sbin/sendmail && \ ln -sf $APP_LIB/etc/msmtprc /etc/msmtprc -COPY app/ $APP_LIB +COPY ./ $APP_LIB EXPOSE 587 586 ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/charts/smarthost/.helmignore b/chart/.helmignore similarity index 100% rename from charts/smarthost/.helmignore rename to chart/.helmignore diff --git a/charts/smarthost/Chart.yaml b/chart/Chart.yaml similarity index 98% rename from charts/smarthost/Chart.yaml rename to chart/Chart.yaml index 4fad90b..26eb506 100644 --- a/charts/smarthost/Chart.yaml +++ b/chart/Chart.yaml @@ -21,4 +21,4 @@ version: 0.0.0 # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "devel" +appVersion: "latest" diff --git a/charts/smarthost/charts/.gitkeep b/chart/charts/.gitkeep similarity index 100% rename from charts/smarthost/charts/.gitkeep rename to chart/charts/.gitkeep diff --git a/charts/smarthost/templates/NOTES.txt b/chart/templates/NOTES.txt similarity index 100% rename from charts/smarthost/templates/NOTES.txt rename to chart/templates/NOTES.txt diff --git a/charts/smarthost/templates/_config.yaml b/chart/templates/_config.yaml similarity index 100% rename from charts/smarthost/templates/_config.yaml rename to chart/templates/_config.yaml diff --git a/charts/smarthost/templates/_helpers.tpl b/chart/templates/_helpers.tpl similarity index 100% rename from charts/smarthost/templates/_helpers.tpl rename to chart/templates/_helpers.tpl diff --git a/charts/smarthost/templates/deployment.yaml b/chart/templates/deployment.yaml similarity index 100% rename from charts/smarthost/templates/deployment.yaml rename to chart/templates/deployment.yaml diff --git a/charts/smarthost/templates/hpa.yaml b/chart/templates/hpa.yaml similarity index 100% rename from charts/smarthost/templates/hpa.yaml rename to chart/templates/hpa.yaml diff --git a/charts/smarthost/templates/service-pp.yaml b/chart/templates/service-pp.yaml similarity index 100% rename from charts/smarthost/templates/service-pp.yaml rename to chart/templates/service-pp.yaml diff --git a/charts/smarthost/templates/service.yaml b/chart/templates/service.yaml similarity index 100% rename from charts/smarthost/templates/service.yaml rename to chart/templates/service.yaml diff --git a/charts/smarthost/templates/serviceaccount.yaml b/chart/templates/serviceaccount.yaml similarity index 100% rename from charts/smarthost/templates/serviceaccount.yaml rename to chart/templates/serviceaccount.yaml diff --git a/charts/smarthost/templates/tests/_test-connection.yaml b/chart/templates/tests/_test-connection.yaml similarity index 100% rename from charts/smarthost/templates/tests/_test-connection.yaml rename to chart/templates/tests/_test-connection.yaml diff --git a/charts/smarthost/values.yaml b/chart/values.yaml similarity index 100% rename from charts/smarthost/values.yaml rename to chart/values.yaml diff --git a/charts/chart-releaser.yaml b/charts/chart-releaser.yaml deleted file mode 100644 index 5a1f3b8..0000000 --- a/charts/chart-releaser.yaml +++ /dev/null @@ -1,2 +0,0 @@ -owner: insios -git-repo: helm-repo diff --git a/devel/bin/config.sh b/devel/bin/config.sh index 434866e..e62786c 100644 --- a/devel/bin/config.sh +++ b/devel/bin/config.sh @@ -26,6 +26,9 @@ fi if [ -z "$LOCAL_SUBMIT_PORT_PP" ]; then LOCAL_SUBMIT_PORT_PP="8586" fi +if [ -z "$HELM_CHART" ]; then + HELM_CHART="./chart" +fi if [ -z "$HELM_NS" ]; then HELM_NS="default" fi diff --git a/devel/bin/helm-install b/devel/bin/helm-install index fb963d0..cf40e1e 100755 --- a/devel/bin/helm-install +++ b/devel/bin/helm-install @@ -7,4 +7,4 @@ helm upgrade --install --atomic --cleanup-on-fail \ --namespace "$HELM_NS" --create-namespace \ $HELM_VALUES \ --set podAnnotations.rollme="$(date)" \ - smarthost ./chart + smarthost $HELM_CHART diff --git a/devel/bin/helm-template b/devel/bin/helm-template index 7b585dd..7adcc79 100755 --- a/devel/bin/helm-template +++ b/devel/bin/helm-template @@ -2,4 +2,4 @@ . ./devel/bin/config.sh helm -helm template smarthost ./chart $HELM_VALUES +helm template smarthost $HELM_CHART $HELM_VALUES