mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-24 13:49:03 +03:00
Merge pull request #15 from acelaya-forks/feature/gh-action-docker-build
Feature/gh action docker build
This commit is contained in:
commit
ca6fb1c656
4 changed files with 34 additions and 41 deletions
24
.github/workflows/docker-image-build.yml
vendored
Normal file
24
.github/workflows/docker-image-build.yml
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
name: Build docker image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Install buildx
|
||||
id: buildx
|
||||
uses: crazy-max/ghaction-docker-buildx@v1
|
||||
with:
|
||||
buildx-version: latest
|
||||
- name: Login to docker hub
|
||||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
||||
- name: Build the image
|
||||
run: bash ./docker/build
|
|
@ -18,14 +18,6 @@ jobs:
|
|||
allow_failures:
|
||||
- php: 'nightly'
|
||||
include:
|
||||
- name: "Docker publish"
|
||||
if: NOT type = pull_request
|
||||
# Overwrite all common steps that have to be different
|
||||
before_install: echo "Before install"
|
||||
install: sudo ./data/infra/ci/install-docker.sh
|
||||
before_script: echo "Before script"
|
||||
script: bash ./docker/build
|
||||
after_success: echo "After success"
|
||||
- name: "CI - 8.0"
|
||||
php: 'nightly'
|
||||
env:
|
||||
|
@ -47,7 +39,6 @@ jobs:
|
|||
on:
|
||||
tags: true
|
||||
|
||||
# Common steps for all jobs
|
||||
before_install:
|
||||
- echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||
- phpenv config-rm xdebug.ini || return 0
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
# install latest docker version
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||
apt-get update
|
||||
apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
|
||||
|
||||
# enable multiarch execution
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
30
docker/build
30
docker/build
|
@ -2,33 +2,23 @@
|
|||
|
||||
set -e
|
||||
|
||||
# PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64"
|
||||
PLATFORMS="linux/amd64"
|
||||
DOCKER_IMAGE="shlinkio/shlink"
|
||||
BUILDX_VER=v0.4.1
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||
PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64"
|
||||
# PLATFORMS="linux/amd64"
|
||||
DOCKER_IMAGE="shlinkio/lab"
|
||||
|
||||
mkdir -vp ~/.docker/cli-plugins/ ~/dockercache
|
||||
curl --silent -L "https://github.com/docker/buildx/releases/download/${BUILDX_VER}/buildx-${BUILDX_VER}.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
|
||||
chmod a+x ~/.docker/cli-plugins/docker-buildx
|
||||
|
||||
docker buildx create --use
|
||||
|
||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
|
||||
# If there is a tag, regardless the branch, build that docker tag and also "stable"
|
||||
if [[ ! -z $TRAVIS_TAG ]]; then
|
||||
TAGS="-t ${DOCKER_IMAGE}:${TRAVIS_TAG#?}"
|
||||
# If ref is not develop, then this is a tag. Build that docker tag and also "stable"
|
||||
if [[ "$GITHUB_REF" != *"develop"* ]]; then
|
||||
TAGS="-t ${DOCKER_IMAGE}:${GITHUB_REF#?}"
|
||||
# Push stable tag only if this is not an alpha or beta tag
|
||||
[[ $TRAVIS_TAG != *"alpha"* && $TRAVIS_TAG != *"beta"* ]] && TAGS="${TAGS} -t ${DOCKER_IMAGE}:stable"
|
||||
[[ $GITHUB_REF != *"alpha"* && $GITHUB_REF != *"beta"* ]] && TAGS="${TAGS} -t ${DOCKER_IMAGE}:stable"
|
||||
|
||||
docker buildx build --push \
|
||||
--build-arg SHLINK_VERSION=${TRAVIS_TAG#?} \
|
||||
--build-arg SHLINK_VERSION=${GITHUB_REF#?} \
|
||||
--platform ${PLATFORMS} \
|
||||
${TAGS} .
|
||||
|
||||
# If build branch is develop, build latest (on main branch, when there's no tag, do not build anything)
|
||||
elif [[ "$TRAVIS_BRANCH" == 'develop' ]]; then
|
||||
# If build branch is develop, build latest
|
||||
elif [[ "$GITHUB_REF" == *"develop"* ]]; then
|
||||
docker buildx build --push \
|
||||
--platform ${PLATFORMS} \
|
||||
-t ${DOCKER_IMAGE}:latest .
|
||||
|
|
Loading…
Reference in a new issue