mirror of https://github.com/thumbsup/thumbsup
chore(build): automatically build and publish the Docker image with Travis CI
Fixes #114.pull/118/head
parent
a51904255c
commit
23b4016923
@ -1,2 +1,3 @@
|
||||
coverage
|
||||
node_modules
|
||||
test-snapshot/output-actual
|
||||
tmp
|
||||
|
@ -1,17 +1,42 @@
|
||||
# Run the whole build inside Docker
|
||||
# Build steps need access to the Docker agent
|
||||
sudo: required
|
||||
services:
|
||||
- docker
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: build
|
||||
script: docker build .
|
||||
- stage: npm release
|
||||
script: echo "Deploying to npm ..."
|
||||
|
||||
# Run all the tests inside Docker
|
||||
|
||||
- stage: Test
|
||||
script: docker build -f Dockerfile.test .
|
||||
|
||||
|
||||
# If this is a tagged commit, publish the package to npm
|
||||
|
||||
- stage: Release npm
|
||||
script: echo "Deploying to npm"
|
||||
deploy:
|
||||
provider: npm
|
||||
email: asyncadventures@gmail.com
|
||||
api_key: $NPM_TOKEN
|
||||
on:
|
||||
tags: true
|
||||
condition: $TRAVIS_TAG =~ ^\d+\.\d+\.\d+$
|
||||
|
||||
# If this is a tagged commit, publish a new Docker image
|
||||
|
||||
- stage: Release Docker
|
||||
script: echo "Deploying to DockerHub"
|
||||
deploy:
|
||||
provider: script
|
||||
script:
|
||||
- DOCKER_IMAGE="thumbsupgallery/thumbsup"
|
||||
- docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}"
|
||||
- docker build -f Dockerfile.release -t "${DOCKER_IMAGE}:TRAVIS_TAG" --build-arg "PACKAGE_VERSION=${TRAVIS_TAG}" .
|
||||
- docker tag "${DOCKER_IMAGE}:${TRAVIS_TAG}" "${DOCKER_IMAGE}:latest"
|
||||
- docker push "${DOCKER_IMAGE}:${TRAVIS_TAG}"
|
||||
- docker push "${DOCKER_IMAGE}:latest"
|
||||
on:
|
||||
tags: true
|
||||
condition: $TRAVIS_TAG =~ ^\d+\.\d+\.\d+$
|
||||
|
@ -0,0 +1,33 @@
|
||||
# ------------------------------------------------
|
||||
# Builder image
|
||||
# ------------------------------------------------
|
||||
|
||||
FROM thumbsupgallery/build:alpine as build
|
||||
|
||||
# Install thumbsup locally
|
||||
WORKDIR /thumbsup
|
||||
ARG PACKAGE_VERSION
|
||||
RUN if [ -z "${PACKAGE_VERSION}" ]; then \
|
||||
echo "Please specify --build-arg PACKAGE_VERSION=<2.4.1>"; \
|
||||
exit 1; \
|
||||
fi;
|
||||
RUN echo "Installing thumbsup@${PACKAGE_VERSION}"
|
||||
RUN npm install thumbsup@${PACKAGE_VERSION}
|
||||
|
||||
# ------------------------------------------------
|
||||
# Runtime image
|
||||
# ------------------------------------------------
|
||||
|
||||
FROM thumbsupgallery/runtime:alpine
|
||||
|
||||
# Use tini as an init process
|
||||
# to ensure all child processes (ffmpeg...) are always terminated properly
|
||||
RUN apk add --update tini
|
||||
ENTRYPOINT ["tini", "-g", "--"]
|
||||
|
||||
# Copy the thumbsup files to the new image
|
||||
COPY --from=build /thumbsup /thumbsup
|
||||
RUN ln -s /thumbsup/node_modules/.bin/thumbsup /usr/local/bin/thumbsup
|
||||
|
||||
# Default command, should be overridden during <docker run>
|
||||
CMD ["thumbsup"]
|
@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Fail the build on any error
|
||||
set -eou pipefail
|
||||
|
||||
trap failure ERR
|
||||
function failure {
|
||||
echo ""
|
||||
echo "=================================="
|
||||
echo " ✘ Build failed"
|
||||
echo "=================================="
|
||||
}
|
||||
|
||||
echo "Run unit tests"
|
||||
npm test
|
||||
|
||||
echo ""
|
||||
echo "=================================="
|
||||
echo " ✔ Build successful"
|
||||
echo "=================================="
|
Loading…
Reference in New Issue