Merge pull request #684 from acelaya-forks/feature/travis-docker-build

Feature/travis docker build
This commit is contained in:
Alejandro Celaya 2020-03-21 15:14:14 +01:00 committed by GitHub
commit 32eb9924e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 41 additions and 29 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
.idea
build
!hooks/build
!docker/build
composer.lock
composer.phar
vendor/

View File

@ -18,7 +18,7 @@ cache:
before_install:
- echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- yes | pecl install swoole
- yes | pecl install swoole-4.4.15
- phpenv config-rm xdebug.ini || return 0
install:
@ -45,9 +45,14 @@ after_success:
# Before deploying, build dist file for current travis tag
before_deploy:
- rm -f ocular.phar
- ./build.sh ${TRAVIS_TAG#?}
- if [[ ! -z $TRAVIS_TAG && "${TRAVIS_PHP_VERSION}" == "7.4" ]]; then ./build.sh ${TRAVIS_TAG#?} ; fi
deploy:
- provider: script
script: bash ./docker/build
on:
condition: $TRAVIS_PULL_REQUEST == 'false'
php: '7.4'
- provider: releases
api_key:
secure: a9dbZchocqeuOViwUeNH54bQR5Sz7rEYXx5b9WPFtnFn9LGKKUaLbA2U91UQ9QKPrcTpsALubUYbw2CnNmvCwzaY+R8lCD3gkU4ohsEnbpnw3deOeixI74sqBHJAuCH9FSaRDGILoBMtUKx2xlzIymFxkIsgIukkGbdkWHDlRWY3oTUUuw1SQ2Xk9KDsbJQtjIc1+G/O6gHaV4qv/R9W8NPmJExKTNDrAZbC1vIUnxqp4UpVo1hst8qPd1at94CndDYM5rG+7imGbdtxTxzamt819qdTO1OfvtctKawNAm7YXZrrWft6c7gI6j6SI4hxd+ZrrPBqbaRFHkZHjnNssO/yn4SaOHFFzccmu0MzvpPCf0qWZwd3sGHVYer1MnR2mHYqU84QPlW3nrHwJjkrpq3+q0JcBY6GsJs+RskHNtkMTKV05Iz6QUI5YZGwTpuXaRm036SmavjGc4IDlMaYCk/NmbB9BKpthJxLdUpczOHpnjXXHziotWD6cfEnbjU3byfD8HY5WrxSjsNT7SKmXN3hRof7bk985ewQVjGT42O3NbnfnqjQQWr/B7/zFTpLR4f526Bkq12CdCyf5lvrbq+POkLVdJ+uFfR7ds248Ue/jBQy6kM1tWmKF9QiwisFlA84eQ4CW3I93Rp97URv+AQa9zmbD0Ve3Udp+g6nF5I=

View File

@ -1,5 +1,4 @@
FROM php:7.4.2-alpine3.11
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
FROM php:7.4.2-alpine3.11 as base
ARG SHLINK_VERSION=2.0.5
ENV SHLINK_VERSION ${SHLINK_VERSION}
@ -9,7 +8,7 @@ ENV LC_ALL "C"
WORKDIR /etc/shlink
RUN \
# Install mysl and calendar
# Install mysql and calendar
docker-php-ext-install -j"$(nproc)" pdo_mysql calendar && \
# Install sqlite
apk add --no-cache sqlite-libs sqlite-dev && \
@ -36,17 +35,21 @@ RUN wget https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8
rm msodbcsql17_17.5.1.1-1_amd64.apk && \
rm mssql-tools_17.5.1.1-1_amd64.apk
# Install shlink
COPY . .
COPY --from=composer:1.9.3 /usr/bin/composer ./composer.phar
RUN rm -rf ./docker && \
php composer.phar install --no-dev --optimize-autoloader --prefer-dist --no-progress --no-interaction && \
php composer.phar clear-cache && \
rm composer.*
# Add shlink to the path to ease running it after container is created
# Install shlink
FROM base as builder
COPY . .
COPY --from=composer:1.10.1 /usr/bin/composer ./composer.phar
RUN php composer.phar install --no-dev --optimize-autoloader --prefer-dist --no-progress --no-interaction && \
sed -i "s/%SHLINK_VERSION%/${SHLINK_VERSION}/g" config/autoload/app_options.global.php
# Prepare final image
FROM base
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
COPY --from=builder /etc/shlink .
RUN ln -s /etc/shlink/bin/cli /usr/local/bin/shlink
RUN sed -i "s/%SHLINK_VERSION%/${SHLINK_VERSION}/g" config/autoload/app_options.global.php
# Expose swoole port
EXPOSE 8080

View File

@ -25,7 +25,7 @@ cd "${builtcontent}"
# Install dependencies
echo "Installing dependencies with $composerBin..."
${composerBin} self-update
${composerBin} install --no-dev --optimize-autoloader --no-progress --no-interaction
${composerBin} install --no-dev --optimize-autoloader --prefer-dist --no-progress --no-interaction
# Delete development files
echo 'Deleting dev files...'

View File

@ -1,6 +1,5 @@
# Shlink Docker image
[![Docker build status](https://img.shields.io/docker/build/shlinkio/shlink.svg?style=flat-square)](https://hub.docker.com/r/shlinkio/shlink/)
[![Docker pulls](https://img.shields.io/docker/pulls/shlinkio/shlink.svg?style=flat-square)](https://hub.docker.com/r/shlinkio/shlink/)
This image provides an easy way to set up [shlink](https://shlink.io) on a container-based runtime.

15
docker/build Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e
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
docker build --build-arg VERSION=${TRAVIS_TAG#?} -t shlinkio/shlink:${TRAVIS_TAG#?} -t shlinkio/shlink:stable .
docker push shlinkio/shlink:${TRAVIS_TAG#?}
docker push shlinkio/shlink:stable
# If build branch is develop, build latest (on master, when there's no tag, do not build anything)
elif [[ "$TRAVIS_BRANCH" == 'develop' ]]; then
docker build -t shlinkio/shlink:latest .
docker push shlinkio/shlink:latest
fi

View File

@ -1,10 +0,0 @@
#!/bin/bash
set -ex
if [[ ${SOURCE_BRANCH} == 'develop' ]]; then
SHLINK_RELEASE='latest'
else
SHLINK_RELEASE=${SOURCE_BRANCH#?}
fi
docker build --build-arg SHLINK_VERSION=${SHLINK_RELEASE} -t ${IMAGE_NAME} .

View File

@ -32,7 +32,7 @@ class ShortUrl extends AbstractEntity
private ?Chronos $validSince = null;
private ?Chronos $validUntil = null;
private ?int $maxVisits = null;
private ?Domain $domain;
private ?Domain $domain = null;
private bool $customSlugWasProvided;
private int $shortCodeLength;

View File

@ -11,7 +11,7 @@ use Shlinkio\Shlink\Common\Entity\AbstractEntity;
class ApiKey extends AbstractEntity
{
private string $key;
private ?Chronos $expirationDate;
private ?Chronos $expirationDate = null;
private bool $enabled;
public function __construct(?Chronos $expirationDate = null)