diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 155a1d17..65817d57 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -12,79 +12,133 @@ on: options: - master - develop + - testing tag: description: 'Add a tag' push: branches: - develop + - testing paths-ignore: - '.github/**' jobs: - push_to_ghcr_io: + build-and-push-it-to-the-limit: runs-on: ubuntu-latest + strategy: + matrix: + architecture: [linux-arm-v7,linux-arm64,linux-amd64] steps: - name: checkout uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${{ github.event.release.tag_name }} - - name: Set current date as env variable - id: date_time - run: echo ::set-output name=NOW::$(date +'%Y-%m-%dT%H:%M:%S') + - name: Prepare + id: prep + run: | + ARCHITECTURE=${{ matrix.architecture }} + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + echo ::set-output name=title::${GITHUB_REPOSITORY,,}:${GITHUB_REF//refs\/heads\//} + echo ::set-output name=revision::${GITHUB_SHA} + echo ::set-output name=source::${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY,,}/tree/${GITHUB_REF//refs\/heads\//} + echo ::set-output name=vendor::${{ github.repository_owner }} + echo ::set-output name=url::${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY,,}/blob/master/README.md + echo ::set-output name=VERSION::${{ github.event.release.tag_name }} + echo ::set-output name=platform::${ARCHITECTURE//-/\/} + echo ::set-output name=cache::${GITHUB_REPOSITORY,,}:${GITHUB_REF//refs\/heads\//}-cache-${{ matrix.architecture }} + echo ::set-output name=tag::${GITHUB_REPOSITORY,,}:${GITHUB_REF//refs\/heads\//}-${GITHUB_SHA:0:7}-${GITHUB_RUN_NUMBER}-${{ matrix.architecture }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GH_PAT }} - - name: build&push master - if: ${{ github.event.release.target_commitish == 'master' }} - run: | - docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park --tag ghcr.io/gilbn/theme.park:${{ steps.get_version.outputs.VERSION }} . - docker push --all-tags ghcr.io/gilbn/theme.park - - name: manual build&push master - if: ${{ github.event.inputs.branch == 'master' }} - run: | - docker build --build-arg TP_RELEASE=${{ github.event.inputs.tag }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park --tag ghcr.io/gilbn/theme.park:${{ github.event.inputs.tag }} . - docker push --all-tags ghcr.io/gilbn/theme.park - - name: build&push develop - if: ${{ github.ref == 'refs/heads/develop' || github.event.inputs.branch == 'develop' }} - run: | - docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park:develop . - docker push --all-tags ghcr.io/gilbn/theme.park - push_to_dockerhub: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${{ github.event.release.tag_name }} - - name: Set current date as env variable - id: date_time - run: echo ::set-output name=NOW::$(date +'%Y-%m-%dT%H:%M:%S') + - name: Login to Docker Hub uses: docker/login-action@v1 with: username: ${{ secrets.DH_USER }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: build&push dh master - if: ${{ github.event.release.target_commitish == 'master' }} - run: | - docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag gilbn/theme.park --tag gilbn/theme.park:${{ steps.get_version.outputs.VERSION }} . - docker push --all-tags gilbn/theme.park - - name: manual build&push dh master - if: ${{ github.event.inputs.branch == 'master' }} - run: | - docker build --build-arg TP_RELEASE=${{ github.event.inputs.tag }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag gilbn/theme.park --tag gilbn/theme.park:${{ github.event.inputs.tag }} . - docker push --all-tags gilbn/theme.park - - name: build&push dh develop - if: ${{ github.ref == 'refs/heads/develop' || github.event.inputs.branch == 'develop' }} - run: | - docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag gilbn/theme.park:develop . - docker push --all-tags gilbn/theme.park + - name: build&push + uses: docker/build-push-action@v2 + with: + push: ${{ github.event_name != 'pull_request' }} + platforms: ${{ steps.prep.outputs.platform }} + file: ./${{ matrix.architecture }}.Dockerfile + cache-from: docker.io/${{ steps.prep.outputs.cache }} + cache-to: docker.io/${{ steps.prep.outputs.cache }} + tags: | + docker.io/${{ steps.prep.outputs.tag }} + ghcr.io/${{ steps.prep.outputs.tag }} + labels: | + org.opencontainers.image.created=${{ steps.prep.outputs.created }} + org.opencontainers.image.title=${{ steps.prep.outputs.title }} + org.opencontainers.image.revision=${{ steps.prep.outputs.revision }} + org.opencontainers.image.source=${{ steps.prep.outputs.source }} + org.opencontainers.image.vendor=${{ steps.prep.outputs.vendor }} + org.opencontainers.image.url=${{ steps.prep.outputs.url }} + org.opencontainers.image.version=${{ steps.prep.outputs.version }} + build-args: | + TP_RELEASE=${{ steps.prep.outputs.VERSION }} + BUILD_DATE=${{ steps.date_time.outputs.created }} + BUILD_ARCHITECTURE=${{ matrix.architecture }} + + publish: + runs-on: ubuntu-latest + strategy: + matrix: + registry: [docker.io, ghcr.io] + needs: [build-and-push-it-to-the-limit] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login to DockerHub + if: matrix.registry == 'docker.io' + uses: docker/login-action@v1 + with: + registry: docker.io + username: ${{ secrets.DH_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + if: matrix.registry == 'ghcr.io' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GH_PAT }} + + - name: Create manifests + env: + DOCKER_CLI_EXPERIMENTAL: enabled + run: | + IMAGE=${{ matrix.registry }}/${GITHUB_REPOSITORY,,} + TAG=${GITHUB_REF//refs\/heads\//} + SOURCE=${IMAGE}:${TAG}-${GITHUB_SHA:0:7}-${GITHUB_RUN_NUMBER} + VERSION=${{ steps.prep.outputs.VERSION }} + [[ -f linux-amd64.Dockerfile ]] && AMD64=${SOURCE}-linux-amd64 + [[ -f linux-arm64.Dockerfile ]] && ARM64=${SOURCE}-linux-arm64 + [[ -f linux-arm-v7.Dockerfile ]] && ARMV7=${SOURCE}-linux-arm-v7 + docker manifest create ${IMAGE}:${TAG} ${AMD64} ${ARM64} ${ARMV7} + docker manifest push ${IMAGE}:${TAG} + if [[! -z "${VERSION}" ]]; then + docker manifest create ${IMAGE}:${TAG}-${VERSION//\~/-} ${AMD64} ${ARM64} ${ARMV7} + docker manifest push ${IMAGE}:${TAG}-${VERSION//\~/-} + docker manifest create ${IMAGE}:${VERSION//\~/-} ${AMD64} ${ARM64} ${ARMV7} + docker manifest push ${IMAGE}:${VERSION//\~/-} + fi + docker manifest create ${IMAGE}:${TAG}-${GITHUB_SHA:0:7} ${AMD64} ${ARM64} ${ARMV7} + docker manifest push ${IMAGE}:${TAG}-${GITHUB_SHA:0:7} + if [[ ${TAG} == master ]]; then + docker manifest create ${IMAGE}:latest ${AMD64} ${ARM64} ${ARMV7} + docker manifest push ${IMAGE}:latest + fi \ No newline at end of file diff --git a/Dockerfile b/linux-amd64.Dockerfile similarity index 85% rename from Dockerfile rename to linux-amd64.Dockerfile index c8bc0f11..5d1e5de9 100644 --- a/Dockerfile +++ b/linux-amd64.Dockerfile @@ -3,8 +3,9 @@ FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.14 # set version label ARG BUILD_DATE ARG TP_RELEASE -LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE}" +LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE} Platform: ${BUILD_ARCHITECTURE}" LABEL maintainer="gilbn" +LABEL org.opencontainers.image.description DESCRIPTION RUN \ echo " ## Installing packages ## " && \ diff --git a/linux-arm-v7.Dockerfile b/linux-arm-v7.Dockerfile new file mode 100644 index 00000000..5f868fb9 --- /dev/null +++ b/linux-arm-v7.Dockerfile @@ -0,0 +1,23 @@ +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm32v7-3.14 + +# set version label +ARG BUILD_DATE +ARG TP_RELEASE +LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE} Platform: ${BUILD_ARCHITECTURE}" +LABEL maintainer="gilbn" +LABEL org.opencontainers.image.description DESCRIPTION + +RUN \ +echo " ## Installing packages ## " && \ +apk add --no-cache --virtual=build-dependencies \ + python3 && \ + echo "**** install theme.park ****" && \ + mkdir -p /app/themepark + +# copy local files +WORKDIR /app +COPY css/ /app/themepark/css/ +COPY resources/ /app/themepark/resources/ +COPY themes.py index.html CNAME /app/themepark/ + +COPY docker/root/ / \ No newline at end of file diff --git a/linux-arm64.Dockerfile b/linux-arm64.Dockerfile new file mode 100644 index 00000000..2ebba47a --- /dev/null +++ b/linux-arm64.Dockerfile @@ -0,0 +1,23 @@ +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.14 + +# set version label +ARG BUILD_DATE +ARG TP_RELEASE +LABEL build_version="Version:- ${VERSION} Build-date:- ${BUILD_DATE} Platform: ${BUILD_ARCHITECTURE}" +LABEL maintainer="gilbn" +LABEL org.opencontainers.image.description DESCRIPTION + +RUN \ +echo " ## Installing packages ## " && \ +apk add --no-cache --virtual=build-dependencies \ + python3 && \ + echo "**** install theme.park ****" && \ + mkdir -p /app/themepark + +# copy local files +WORKDIR /app +COPY css/ /app/themepark/css/ +COPY resources/ /app/themepark/resources/ +COPY themes.py index.html CNAME /app/themepark/ + +COPY docker/root/ / \ No newline at end of file