2020-10-04 21:53:38 +00:00
|
|
|
name: Docker
|
|
|
|
|
|
|
|
on:
|
2020-10-10 18:15:34 +00:00
|
|
|
#schedule:
|
|
|
|
# - cron: '0 4 * * *' # everyday at 4:00 AM UTC
|
2020-10-04 21:53:38 +00:00
|
|
|
push:
|
|
|
|
branches:
|
2023-12-14 15:06:20 +00:00
|
|
|
- main
|
2020-10-04 21:53:38 +00:00
|
|
|
tags:
|
|
|
|
- v*
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: Build
|
2020-10-08 19:43:13 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- ubuntu-latest
|
2020-10-18 17:18:51 +00:00
|
|
|
docker_pkg:
|
|
|
|
- debian
|
|
|
|
- alpine
|
2021-02-07 20:49:04 +00:00
|
|
|
optional_deps:
|
|
|
|
- true
|
|
|
|
- false
|
2021-09-07 17:52:28 +00:00
|
|
|
include:
|
|
|
|
- os: ubuntu-latest
|
|
|
|
docker_pkg: distroless
|
|
|
|
optional_deps: false
|
2022-08-11 09:27:35 +00:00
|
|
|
- os: ubuntu-latest
|
|
|
|
docker_pkg: debian-plugins
|
|
|
|
optional_deps: true
|
2020-10-04 21:53:38 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-03-03 11:44:56 +00:00
|
|
|
uses: actions/checkout@v3
|
2020-10-04 21:53:38 +00:00
|
|
|
|
|
|
|
- name: Gather image information
|
|
|
|
id: info
|
|
|
|
run: |
|
|
|
|
VERSION=noop
|
2021-02-07 20:49:04 +00:00
|
|
|
DOCKERFILE=Dockerfile
|
2020-10-17 20:14:04 +00:00
|
|
|
MINOR=""
|
|
|
|
MAJOR=""
|
2022-12-18 14:21:32 +00:00
|
|
|
FEATURES="nopgxregisterdefaulttypes"
|
2020-10-04 21:53:38 +00:00
|
|
|
if [ "${{ github.event_name }}" = "schedule" ]; then
|
|
|
|
VERSION=nightly
|
|
|
|
elif [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
|
|
elif [[ $GITHUB_REF == refs/heads/* ]]; then
|
|
|
|
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
|
|
|
|
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
|
|
|
|
VERSION=edge
|
|
|
|
fi
|
|
|
|
elif [[ $GITHUB_REF == refs/pull/* ]]; then
|
|
|
|
VERSION=pr-${{ github.event.number }}
|
|
|
|
fi
|
2020-10-17 20:14:04 +00:00
|
|
|
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
|
|
|
MINOR=${VERSION%.*}
|
|
|
|
MAJOR=${MINOR%.*}
|
|
|
|
fi
|
2020-11-12 21:40:53 +00:00
|
|
|
VERSION_SLIM="${VERSION}-slim"
|
2020-10-08 19:43:13 +00:00
|
|
|
if [[ $DOCKER_PKG == alpine ]]; then
|
2020-10-17 20:14:04 +00:00
|
|
|
VERSION="${VERSION}-alpine"
|
2020-11-12 21:40:53 +00:00
|
|
|
VERSION_SLIM="${VERSION}-slim"
|
2021-02-07 20:49:04 +00:00
|
|
|
DOCKERFILE=Dockerfile.alpine
|
2021-09-07 17:52:28 +00:00
|
|
|
elif [[ $DOCKER_PKG == distroless ]]; then
|
|
|
|
VERSION="${VERSION}-distroless"
|
|
|
|
VERSION_SLIM="${VERSION}-slim"
|
2021-09-06 17:10:28 +00:00
|
|
|
DOCKERFILE=Dockerfile.distroless
|
2022-12-18 14:21:32 +00:00
|
|
|
FEATURES="${FEATURES},nosqlite"
|
2022-08-11 09:27:35 +00:00
|
|
|
elif [[ $DOCKER_PKG == debian-plugins ]]; then
|
|
|
|
VERSION="${VERSION}-plugins"
|
|
|
|
VERSION_SLIM="${VERSION}-slim"
|
2021-09-06 17:10:28 +00:00
|
|
|
fi
|
2020-11-13 20:55:53 +00:00
|
|
|
DOCKER_IMAGES=("drakkan/sftpgo" "ghcr.io/drakkan/sftpgo")
|
|
|
|
TAGS="${DOCKER_IMAGES[0]}:${VERSION}"
|
|
|
|
TAGS_SLIM="${DOCKER_IMAGES[0]}:${VERSION_SLIM}"
|
|
|
|
|
|
|
|
for DOCKER_IMAGE in ${DOCKER_IMAGES[@]}; do
|
|
|
|
if [[ ${DOCKER_IMAGE} != ${DOCKER_IMAGES[0]} ]]; then
|
|
|
|
TAGS="${TAGS},${DOCKER_IMAGE}:${VERSION}"
|
|
|
|
TAGS_SLIM="${TAGS_SLIM},${DOCKER_IMAGE}:${VERSION_SLIM}"
|
|
|
|
fi
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
|
|
if [[ $DOCKER_PKG == debian ]]; then
|
|
|
|
if [[ -n $MAJOR && -n $MINOR ]]; then
|
|
|
|
TAGS="${TAGS},${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR}"
|
|
|
|
TAGS_SLIM="${TAGS_SLIM},${DOCKER_IMAGE}:${MINOR}-slim,${DOCKER_IMAGE}:${MAJOR}-slim"
|
|
|
|
fi
|
|
|
|
TAGS="${TAGS},${DOCKER_IMAGE}:latest"
|
|
|
|
TAGS_SLIM="${TAGS_SLIM},${DOCKER_IMAGE}:slim"
|
2021-09-06 17:10:28 +00:00
|
|
|
elif [[ $DOCKER_PKG == distroless ]]; then
|
|
|
|
if [[ -n $MAJOR && -n $MINOR ]]; then
|
2021-09-07 17:52:28 +00:00
|
|
|
TAGS="${TAGS},${DOCKER_IMAGE}:${MINOR}-distroless,${DOCKER_IMAGE}:${MAJOR}-distroless"
|
2021-09-06 17:10:28 +00:00
|
|
|
TAGS_SLIM="${TAGS_SLIM},${DOCKER_IMAGE}:${MINOR}-distroless-slim,${DOCKER_IMAGE}:${MAJOR}-distroless-slim"
|
|
|
|
fi
|
2021-09-07 17:52:28 +00:00
|
|
|
TAGS="${TAGS},${DOCKER_IMAGE}:distroless"
|
|
|
|
TAGS_SLIM="${TAGS_SLIM},${DOCKER_IMAGE}:distroless-slim"
|
2022-09-03 14:29:07 +00:00
|
|
|
elif [[ $DOCKER_PKG == debian-plugins ]]; then
|
|
|
|
if [[ -n $MAJOR && -n $MINOR ]]; then
|
|
|
|
TAGS="${TAGS},${DOCKER_IMAGE}:${MINOR}-plugins,${DOCKER_IMAGE}:${MAJOR}-plugins"
|
|
|
|
TAGS_SLIM="${TAGS_SLIM},${DOCKER_IMAGE}:${MINOR}-plugins-slim,${DOCKER_IMAGE}:${MAJOR}-plugins-slim"
|
|
|
|
fi
|
|
|
|
TAGS="${TAGS},${DOCKER_IMAGE}:plugins"
|
|
|
|
TAGS_SLIM="${TAGS_SLIM},${DOCKER_IMAGE}:plugins-slim"
|
2020-11-13 20:55:53 +00:00
|
|
|
else
|
|
|
|
if [[ -n $MAJOR && -n $MINOR ]]; then
|
|
|
|
TAGS="${TAGS},${DOCKER_IMAGE}:${MINOR}-alpine,${DOCKER_IMAGE}:${MAJOR}-alpine"
|
|
|
|
TAGS_SLIM="${TAGS_SLIM},${DOCKER_IMAGE}:${MINOR}-alpine-slim,${DOCKER_IMAGE}:${MAJOR}-alpine-slim"
|
|
|
|
fi
|
|
|
|
TAGS="${TAGS},${DOCKER_IMAGE}:alpine"
|
|
|
|
TAGS_SLIM="${TAGS_SLIM},${DOCKER_IMAGE}:alpine-slim"
|
2020-10-17 20:14:04 +00:00
|
|
|
fi
|
2020-10-08 19:43:13 +00:00
|
|
|
fi
|
2020-11-13 20:55:53 +00:00
|
|
|
done
|
|
|
|
|
2021-02-07 20:49:04 +00:00
|
|
|
if [[ $OPTIONAL_DEPS == true ]]; then
|
2022-10-13 11:11:22 +00:00
|
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
|
|
|
|
echo "full=true" >> $GITHUB_OUTPUT
|
2021-02-07 20:49:04 +00:00
|
|
|
else
|
2022-10-13 11:11:22 +00:00
|
|
|
echo "version=${VERSION_SLIM}" >> $GITHUB_OUTPUT
|
|
|
|
echo "tags=${TAGS_SLIM}" >> $GITHUB_OUTPUT
|
|
|
|
echo "full=false" >> $GITHUB_OUTPUT
|
2021-02-07 20:49:04 +00:00
|
|
|
fi
|
2022-08-11 09:27:35 +00:00
|
|
|
if [[ $DOCKER_PKG == debian-plugins ]]; then
|
2022-10-13 11:11:22 +00:00
|
|
|
echo "plugins=true" >> $GITHUB_OUTPUT
|
2022-08-11 09:27:35 +00:00
|
|
|
else
|
2022-10-13 11:11:22 +00:00
|
|
|
echo "plugins=false" >> $GITHUB_OUTPUT
|
2022-08-11 09:27:35 +00:00
|
|
|
fi
|
2022-10-13 11:11:22 +00:00
|
|
|
echo "dockerfile=${DOCKERFILE}" >> $GITHUB_OUTPUT
|
2022-12-18 14:21:32 +00:00
|
|
|
echo "features=${FEATURES}" >> $GITHUB_OUTPUT
|
2022-10-13 11:11:22 +00:00
|
|
|
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
|
|
|
|
echo "sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
|
2020-10-08 19:43:13 +00:00
|
|
|
env:
|
|
|
|
DOCKER_PKG: ${{ matrix.docker_pkg }}
|
2021-02-07 20:49:04 +00:00
|
|
|
OPTIONAL_DEPS: ${{ matrix.optional_deps }}
|
2020-10-04 21:53:38 +00:00
|
|
|
|
|
|
|
- name: Set up QEMU
|
2022-05-09 09:19:29 +00:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2020-10-04 21:53:38 +00:00
|
|
|
|
2021-02-07 20:49:04 +00:00
|
|
|
- name: Set up builder
|
2022-05-09 09:19:29 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2021-02-07 20:49:04 +00:00
|
|
|
id: builder
|
2020-10-04 21:53:38 +00:00
|
|
|
|
2020-10-18 19:52:42 +00:00
|
|
|
- name: Login to Docker Hub
|
2022-05-09 09:19:29 +00:00
|
|
|
uses: docker/login-action@v2
|
2020-10-05 14:17:10 +00:00
|
|
|
with:
|
2020-10-14 05:46:36 +00:00
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2020-11-13 20:55:53 +00:00
|
|
|
if: ${{ github.event_name != 'pull_request' }}
|
2020-10-18 17:18:51 +00:00
|
|
|
|
|
|
|
- name: Login to GitHub Container Registry
|
2022-05-09 09:19:29 +00:00
|
|
|
uses: docker/login-action@v2
|
2020-10-18 17:18:51 +00:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
2021-08-18 12:39:56 +00:00
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2020-11-13 20:55:53 +00:00
|
|
|
if: ${{ github.event_name != 'pull_request' }}
|
2020-10-04 21:53:38 +00:00
|
|
|
|
2021-02-07 20:49:04 +00:00
|
|
|
- name: Build and push
|
2022-05-09 09:19:29 +00:00
|
|
|
uses: docker/build-push-action@v3
|
2020-10-04 21:53:38 +00:00
|
|
|
with:
|
2021-08-18 12:39:56 +00:00
|
|
|
context: .
|
2021-02-07 20:49:04 +00:00
|
|
|
builder: ${{ steps.builder.outputs.name }}
|
2020-10-08 19:43:13 +00:00
|
|
|
file: ./${{ steps.info.outputs.dockerfile }}
|
2022-03-25 08:32:48 +00:00
|
|
|
platforms: linux/amd64,linux/arm64,linux/ppc64le
|
2020-10-05 14:17:10 +00:00
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
2020-10-04 21:53:38 +00:00
|
|
|
tags: ${{ steps.info.outputs.tags }}
|
2020-10-04 22:17:17 +00:00
|
|
|
build-args: |
|
|
|
|
COMMIT_SHA=${{ steps.info.outputs.sha }}
|
2021-02-07 20:49:04 +00:00
|
|
|
INSTALL_OPTIONAL_PACKAGES=${{ steps.info.outputs.full }}
|
2022-08-11 09:27:35 +00:00
|
|
|
DOWNLOAD_PLUGINS=${{ steps.info.outputs.plugins }}
|
2022-12-18 14:21:32 +00:00
|
|
|
FEATURES=${{ steps.info.outputs.features }}
|
2020-10-04 21:53:38 +00:00
|
|
|
labels: |
|
2020-10-09 18:25:42 +00:00
|
|
|
org.opencontainers.image.title=SFTPGo
|
2021-11-29 16:58:10 +00:00
|
|
|
org.opencontainers.image.description=Fully featured and highly configurable SFTP server with optional HTTP, FTP/S and WebDAV support
|
2021-09-27 08:25:21 +00:00
|
|
|
org.opencontainers.image.url=https://github.com/drakkan/sftpgo
|
|
|
|
org.opencontainers.image.documentation=https://github.com/drakkan/sftpgo/blob/${{ github.sha }}/docker/README.md
|
|
|
|
org.opencontainers.image.source=https://github.com/drakkan/sftpgo
|
2020-10-04 21:53:38 +00:00
|
|
|
org.opencontainers.image.version=${{ steps.info.outputs.version }}
|
|
|
|
org.opencontainers.image.created=${{ steps.info.outputs.created }}
|
|
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
2022-06-27 16:04:24 +00:00
|
|
|
org.opencontainers.image.licenses=AGPL-3.0-only
|