mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-28 20:41:41 +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:
|
allow_failures:
|
||||||
- php: 'nightly'
|
- php: 'nightly'
|
||||||
include:
|
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"
|
- name: "CI - 8.0"
|
||||||
php: 'nightly'
|
php: 'nightly'
|
||||||
env:
|
env:
|
||||||
|
@ -47,7 +39,6 @@ jobs:
|
||||||
on:
|
on:
|
||||||
tags: true
|
tags: true
|
||||||
|
|
||||||
# Common steps for all jobs
|
|
||||||
before_install:
|
before_install:
|
||||||
- echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
- echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||||
- phpenv config-rm xdebug.ini || return 0
|
- 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
|
set -e
|
||||||
|
|
||||||
# PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64"
|
PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64"
|
||||||
PLATFORMS="linux/amd64"
|
# PLATFORMS="linux/amd64"
|
||||||
DOCKER_IMAGE="shlinkio/shlink"
|
DOCKER_IMAGE="shlinkio/lab"
|
||||||
BUILDX_VER=v0.4.1
|
|
||||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
|
||||||
|
|
||||||
mkdir -vp ~/.docker/cli-plugins/ ~/dockercache
|
# If ref is not develop, then this is a tag. Build that docker tag and also "stable"
|
||||||
curl --silent -L "https://github.com/docker/buildx/releases/download/${BUILDX_VER}/buildx-${BUILDX_VER}.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
|
if [[ "$GITHUB_REF" != *"develop"* ]]; then
|
||||||
chmod a+x ~/.docker/cli-plugins/docker-buildx
|
TAGS="-t ${DOCKER_IMAGE}:${GITHUB_REF#?}"
|
||||||
|
|
||||||
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#?}"
|
|
||||||
# Push stable tag only if this is not an alpha or beta tag
|
# 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 \
|
docker buildx build --push \
|
||||||
--build-arg SHLINK_VERSION=${TRAVIS_TAG#?} \
|
--build-arg SHLINK_VERSION=${GITHUB_REF#?} \
|
||||||
--platform ${PLATFORMS} \
|
--platform ${PLATFORMS} \
|
||||||
${TAGS} .
|
${TAGS} .
|
||||||
|
|
||||||
# If build branch is develop, build latest (on main branch, when there's no tag, do not build anything)
|
# If build branch is develop, build latest
|
||||||
elif [[ "$TRAVIS_BRANCH" == 'develop' ]]; then
|
elif [[ "$GITHUB_REF" == *"develop"* ]]; then
|
||||||
docker buildx build --push \
|
docker buildx build --push \
|
||||||
--platform ${PLATFORMS} \
|
--platform ${PLATFORMS} \
|
||||||
-t ${DOCKER_IMAGE}:latest .
|
-t ${DOCKER_IMAGE}:latest .
|
||||||
|
|
Loading…
Add table
Reference in a new issue