mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Merge pull request #270 from acelaya-forks/feature/parallel-docker-build
Feature/parallel docker build
This commit is contained in:
commit
c670d86955
6 changed files with 71 additions and 30 deletions
|
@ -4,3 +4,4 @@
|
||||||
./node_modules
|
./node_modules
|
||||||
./test
|
./test
|
||||||
./shlink-web-client.gif
|
./shlink-web-client.gif
|
||||||
|
./dist
|
||||||
|
|
45
.travis.yml
45
.travis.yml
|
@ -1,7 +1,21 @@
|
||||||
|
dist: bionic
|
||||||
|
|
||||||
language: node_js
|
language: node_js
|
||||||
|
|
||||||
node_js:
|
jobs:
|
||||||
- "12.14.1"
|
fast_finish: true
|
||||||
|
include:
|
||||||
|
- name: "Docker publish"
|
||||||
|
node_js: '12.16.3'
|
||||||
|
if: NOT type = pull_request
|
||||||
|
env:
|
||||||
|
- DOCKER_PUBLISH="true"
|
||||||
|
- name: "CI"
|
||||||
|
node_js: '12.16.3'
|
||||||
|
env:
|
||||||
|
- DOCKER_PUBLISH="false"
|
||||||
|
allow_failures:
|
||||||
|
- name: "Docker publish"
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
|
@ -11,35 +25,34 @@ services:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- npm ci
|
- if [[ ${DOCKER_PUBLISH} == 'true' ]]; then sudo bash ./scripts/docker/install-docker ; fi
|
||||||
|
- if [[ ${DOCKER_PUBLISH} == 'false' ]]; then npm ci ; fi
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- echo "Building commit range ${TRAVIS_COMMIT_RANGE}"
|
- if [[ ${DOCKER_PUBLISH} == 'false' ]]; then echo "Building commit range ${TRAVIS_COMMIT_RANGE}" ; fi
|
||||||
- export MUTATION_FILES=$(git diff ${TRAVIS_COMMIT_RANGE:-origin/master} --name-only | grep -E 'src\/(.*).(js|ts|jsx|tsx)$' | paste -sd ",")
|
- if [[ ${DOCKER_PUBLISH} == 'false' ]]; then export MUTATION_FILES=$(git diff ${TRAVIS_COMMIT_RANGE:-origin/master} --name-only | grep -E 'src\/(.*).(js|ts|jsx|tsx)$' | paste -sd ",") ; fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- npm run lint
|
- if [[ ${DOCKER_PUBLISH} == 'true' ]]; then bash ./scripts/docker/build ; fi
|
||||||
- npm run test:ci
|
- if [[ ${DOCKER_PUBLISH} == 'false' ]]; then npm run lint ; fi
|
||||||
- if [[ $TRAVIS_PULL_REQUEST != 'false' ]]; then docker build -t shlink-web-client:test . ; fi
|
- if [[ ${DOCKER_PUBLISH} == 'false' ]]; then npm run test:ci ; fi
|
||||||
- if [[ $TRAVIS_PULL_REQUEST != 'false' ]]; then npm run mutate:ci ; fi
|
- if [[ ${DOCKER_PUBLISH} == 'false' ]]; then docker build -t shlink-web-client:test . ; fi
|
||||||
|
- if [[ ${DOCKER_PUBLISH} == 'false' ]]; then npm run mutate:ci ; fi
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- node_modules/.bin/ocular coverage/clover.xml
|
- if [[ ${DOCKER_PUBLISH} == 'false' ]]; then node_modules/.bin/ocular coverage/clover.xml ; fi
|
||||||
|
|
||||||
# Before deploying, build dist file for current travis tag
|
# Before deploying, build dist file for current travis tag
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- if [[ ! -z $TRAVIS_TAG ]]; then npm run build ${TRAVIS_TAG#?} ; fi
|
- if [[ ! -z $TRAVIS_TAG && ${DOCKER_PUBLISH} == 'false' ]]; then npm run build ${TRAVIS_TAG#?} ; fi
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
- provider: script
|
|
||||||
script: bash ./scripts/docker/build
|
|
||||||
on:
|
|
||||||
all_branches: true
|
|
||||||
condition: $TRAVIS_PULL_REQUEST == 'false'
|
|
||||||
- provider: releases
|
- provider: releases
|
||||||
api_key:
|
api_key:
|
||||||
secure: jBvPwC7EAbViaNR83rwMSt5XQDK0Iu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cf2ThBNEyJQuiEwAQe4u7yAxY6R5ovEdvHBSIg4w1E5/Mxy5SMTCUlIAv6H7QQ1X9Z/zJm9HH5KeKz5tsHvQ/RIdSpgHXq/tC8o4Yup/LCFucXfrgvy/8pJoO1UpOlmvm62974NFfo0EG5YWwv6brUqz3QXpMjb8sWqgjltYMYJX3J7WZ34rIc+zt4NAmfhqgczaOC4pUGCiJ8jX3rMWIaQRn1AJ+5V337jL9fNDpTHny4phQjHrMJ1e0HZuNp0Xb5Q8wgqDPM=
|
||||||
file: "./dist/shlink-web-client_${TRAVIS_TAG#?}_dist.zip"
|
file: "./dist/shlink-web-client_${TRAVIS_TAG#?}_dist.zip"
|
||||||
skip_cleanup: true
|
skip_cleanup: true
|
||||||
on:
|
on:
|
||||||
|
all_branches: true
|
||||||
|
condition: ${DOCKER_PUBLISH} == 'false'
|
||||||
tags: true
|
tags: true
|
||||||
|
|
11
Dockerfile
11
Dockerfile
|
@ -1,16 +1,11 @@
|
||||||
FROM node:12.14.1-alpine as node
|
FROM node:12.16.3-alpine as node
|
||||||
COPY . /shlink-web-client
|
COPY . /shlink-web-client
|
||||||
ARG VERSION="latest"
|
ARG VERSION="latest"
|
||||||
ENV VERSION ${VERSION}
|
ENV VERSION ${VERSION}
|
||||||
RUN cd /shlink-web-client && \
|
RUN cd /shlink-web-client && \
|
||||||
UNCOMPRESSED="shlink-web-client_${VERSION}_dist" && \
|
npm install && npm run build -- ${VERSION} --no-dist
|
||||||
DIST_FILE="./dist/${UNCOMPRESSED}.zip" && \
|
|
||||||
# If a dist file already exists, just unzip it
|
|
||||||
if [[ -f ${DIST_FILE} ]]; then unzip ${DIST_FILE} && mv ./${UNCOMPRESSED} ./build ; fi && \
|
|
||||||
# If no dist file exsts, build from scratch
|
|
||||||
if [[ ! -f ${DIST_FILE} ]]; then npm install && npm run build -- ${VERSION} --no-dist ; fi
|
|
||||||
|
|
||||||
FROM nginx:1.17.7-alpine
|
FROM nginx:1.17.10-alpine
|
||||||
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
|
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
|
||||||
RUN rm -r /usr/share/nginx/html && rm /etc/nginx/conf.d/default.conf
|
RUN rm -r /usr/share/nginx/html && rm /etc/nginx/conf.d/default.conf
|
||||||
COPY config/docker/nginx.conf /etc/nginx/conf.d/default.conf
|
COPY config/docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
|
@ -3,7 +3,7 @@ version: '3'
|
||||||
services:
|
services:
|
||||||
shlink_web_client_node:
|
shlink_web_client_node:
|
||||||
container_name: shlink_web_client_node
|
container_name: shlink_web_client_node
|
||||||
image: node:12.14.1-alpine
|
image: node:12.16.3-alpine
|
||||||
command: /bin/sh -c "cd /home/shlink/www && npm install && npm run start"
|
command: /bin/sh -c "cd /home/shlink/www && npm install && npm run start"
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/home/shlink/www
|
- ./:/home/shlink/www
|
||||||
|
|
|
@ -1,13 +1,33 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
#PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64"
|
||||||
|
PLATFORMS="linux/amd64"
|
||||||
|
DOCKER_IMAGE="shlinkio/shlink-web-client"
|
||||||
|
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 [[ -z $TRAVIS_TAG ]]; then
|
if [[ -z $TRAVIS_TAG ]]; then
|
||||||
docker build -t shlinkio/shlink-web-client:latest .
|
docker buildx build --push \
|
||||||
docker push shlinkio/shlink-web-client:latest
|
--platform ${PLATFORMS} \
|
||||||
|
-t ${DOCKER_IMAGE}:latest .
|
||||||
|
|
||||||
else
|
else
|
||||||
docker build --build-arg VERSION=${TRAVIS_TAG#?} -t shlinkio/shlink-web-client:${TRAVIS_TAG#?} -t shlinkio/shlink-web-client:stable .
|
TAGS="-t ${DOCKER_IMAGE}:${TRAVIS_TAG#?}"
|
||||||
docker push shlinkio/shlink-web-client:${TRAVIS_TAG#?}
|
# Push stable tag only if this is not an alpha or beta release
|
||||||
docker push shlinkio/shlink-web-client:stable
|
[[ $TRAVIS_TAG != *"alpha"* && $TRAVIS_TAG != *"beta"* ]] && TAGS="${TAGS} -t ${DOCKER_IMAGE}:stable"
|
||||||
|
|
||||||
|
docker buildx build --push \
|
||||||
|
--build-arg SHLINK_VERSION=${TRAVIS_TAG#?} \
|
||||||
|
--platform ${PLATFORMS} \
|
||||||
|
${TAGS} .
|
||||||
fi
|
fi
|
||||||
|
|
12
scripts/docker/install-docker
Executable file
12
scripts/docker/install-docker
Executable 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
|
Loading…
Reference in a new issue