Add multi arch support

This commit is contained in:
Cédric Laubacher 2020-05-05 21:58:23 +02:00
parent 22cc9ace4d
commit fa646b0176
No known key found for this signature in database
GPG Key ID: 3BCC42B8F9C2AC7D
4 changed files with 49 additions and 16 deletions

View File

@ -1,3 +1,5 @@
dist: bionic
language: php language: php
branches: branches:
@ -15,6 +17,7 @@ cache:
- $HOME/.composer/cache/files - $HOME/.composer/cache/files
before_install: before_install:
- sudo ./data/infra/ci/install-docker.sh
- sudo ./data/infra/ci/install-ms-odbc.sh - sudo ./data/infra/ci/install-ms-odbc.sh
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms shlink_db shlink_db_postgres shlink_db_maria - docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms shlink_db shlink_db_postgres shlink_db_maria
- yes | pecl install pdo_sqlsrv swoole-4.4.15 - yes | pecl install pdo_sqlsrv swoole-4.4.15

View File

@ -23,18 +23,25 @@ RUN \
apk add --no-cache libzip-dev zlib-dev libpng-dev && \ apk add --no-cache libzip-dev zlib-dev libpng-dev && \
docker-php-ext-install -j"$(nproc)" zip gd docker-php-ext-install -j"$(nproc)" zip gd
# Install swoole and sqlsrv driver # Install sqlsrv driver
RUN wget https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.1.1-1_amd64.apk && \ RUN if [ $(uname -m) == "x86_64" ]; then \
wget https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.1.1-1_amd64.apk && \
wget https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_17.5.1.1-1_amd64.apk && \ wget https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_17.5.1.1-1_amd64.apk && \
apk add --allow-untrusted msodbcsql17_17.5.1.1-1_amd64.apk && \ apk add --allow-untrusted msodbcsql17_17.5.1.1-1_amd64.apk && \
apk add --allow-untrusted mssql-tools_17.5.1.1-1_amd64.apk && \ apk add --allow-untrusted mssql-tools_17.5.1.1-1_amd64.apk && \
apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS unixodbc-dev && \ apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS unixodbc-dev && \
pecl install swoole-${SWOOLE_VERSION} pdo_sqlsrv && \ pecl install pdo_sqlsrv && \
docker-php-ext-enable swoole pdo_sqlsrv && \ docker-php-ext-enable pdo_sqlsrv && \
apk del .phpize-deps && \ apk del .phpize-deps && \
rm msodbcsql17_17.5.1.1-1_amd64.apk && \ rm msodbcsql17_17.5.1.1-1_amd64.apk && \
rm mssql-tools_17.5.1.1-1_amd64.apk rm mssql-tools_17.5.1.1-1_amd64.apk ; \
fi
# Install swoole
RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS && \
pecl install swoole-${SWOOLE_VERSION} && \
docker-php-ext-enable swoole && \
apk del .phpize-deps
# Install shlink # Install shlink
FROM base as builder FROM base as builder

12
data/infra/ci/install-docker.sh Executable file
View File

@ -0,0 +1,12 @@
#!/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

View File

@ -1,15 +1,26 @@
#!/bin/bash #!/bin/bash
set -e set -e
BUILDX_VER=v0.4.1
export DOCKER_CLI_EXPERIMENTAL=enabled
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 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 there is a tag, regardless the branch, build that docker tag and also "stable"
if [[ ! -z $TRAVIS_TAG ]]; then if [[ ! -z $TRAVIS_TAG ]]; then
docker build --build-arg SHLINK_VERSION=${TRAVIS_TAG#?} -t shlinkio/shlink:${TRAVIS_TAG#?} -t shlinkio/shlink:stable . docker buildx build --push \
docker push shlinkio/shlink:${TRAVIS_TAG#?} --build-arg SHLINK_VERSION=${TRAVIS_TAG#?} \
docker push shlinkio/shlink:stable --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
-t shlinkio/shlink:${TRAVIS_TAG#?} -t shlinkio/shlink:stable .
# If build branch is develop, build latest (on master, when there's no tag, do not build anything) # If build branch is develop, build latest (on master, when there's no tag, do not build anything)
elif [[ "$TRAVIS_BRANCH" == 'develop' ]]; then elif [[ "$TRAVIS_BRANCH" == 'develop' ]]; then
docker build -t shlinkio/shlink:latest . docker buildx build --push \
docker push shlinkio/shlink:latest --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
-t shlinkio/shlink:latest .
fi fi