1
1
mirror of https://github.com/aelve/guide.git synced 2025-01-08 23:39:18 +03:00

[WIP] Push a Docker image after a Travis build (#252)

Push a Docker image after a Travis build
This commit is contained in:
Artyom Kazak 2018-12-28 15:07:18 +11:00 committed by GitHub
parent ca86929e39
commit 1758dab793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 9 deletions

View File

@ -1,18 +1,17 @@
sudo: true
dist: xenial
language: c
language: generic
addons:
apt:
sources:
- google-chrome
packages:
# GHC
- libgmp-dev
# Selenium
- xvfb
# Testcafe
- google-chrome-stable fluxbox
- fluxbox
chrome: stable
before_install:
- # start your web application and listen on `localhost`
@ -23,6 +22,9 @@ cache:
- $HOME/.stack
- .stack-work
- back/.stack-work
- back/static/js # Needed so that bundle.js would persist to the
# "Push Docker image" stage and beyond - without it
# the backend doesn't work and the tests don't run.
timeout: 1000
jobs:
@ -37,7 +39,7 @@ jobs:
script:
- stack --no-terminal --install-ghc test --no-run-tests --dependencies-only
- stage: "Build and test the backend"
- stage: "Build the backend"
before_script:
# Install Stack
- mkdir -p ~/.local/bin
@ -45,8 +47,21 @@ jobs:
- >-
travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 |
tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
script:
- stack --no-terminal build
- stage: "Upload a Docker image for the backend"
script:
- export BRANCH="$(echo "$TRAVIS_BRANCH" | tr '/' '-')"
- make back/travis-docker "tag=$BRANCH--back"
- docker login quay.io -u "$DOCKER_USER" -p "$DOCKER_PASS"
- docker push "quay.io/aelve/guide:$BRANCH--back"
if: type = push
- stage: "Test the backend"
before_script:
# Install chromedriver
- wget http://chromedriver.storage.googleapis.com/2.40/chromedriver_linux64.zip
- wget http://chromedriver.storage.googleapis.com/2.45/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- chmod +x chromedriver
- sudo mv -f chromedriver /usr/local/share/chromedriver
@ -55,11 +70,10 @@ jobs:
# Run selenium-server
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- travis_retry wget http://selenium-release.storage.googleapis.com/3.6/selenium-server-standalone-3.6.0.jar
- java -jar selenium-server-standalone-3.6.0.jar 2> /dev/null &
- travis_retry wget https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar -O selenium.jar
- java -jar selenium.jar 2> /dev/null &
- sleep 15
script:
- stack --no-terminal build
- stack --no-terminal test
- make back/test-db

View File

@ -1,3 +1,5 @@
SHELL := /bin/bash
# Build the project
.PHONY: back
back:
@ -30,3 +32,17 @@ back/test-db: back
.PHONY: back/run
back/run:
stack exec --cwd back -- guide
# Create a Docker image for the backend; will only work on Travis because
# the binary has to have been compiled on Ubuntu Xenial (the OS used in the
# Docker file)
.PHONY: back/travis-docker
back/travis-docker:
rm -rf docker/back/files && mkdir docker/back/files
git clone --depth 1 https://github.com/aelve/guide-database.git \
docker/back/files/state
rm -rf docker/back/files/state/.git
cp .stack-work/install/*/*/*/bin/guide docker/back/files/
cp -R back/{static,templates} docker/back/files/
docker build docker/back -t quay.io/aelve/guide:$(tag)
rm -rf docker/back/files

12
docker/back/Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM ubuntu:xenial
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
RUN apt update && apt install -y libgmp-dev
WORKDIR /opt/guide
COPY files ./
CMD ./guide