Skip to content

Commit

Permalink
build slim image
Browse files Browse the repository at this point in the history
  • Loading branch information
aperrin66 authored and akorosov committed Oct 2, 2020
1 parent 704715d commit 48f0e2d
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 34 deletions.
102 changes: 71 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,79 @@
language: shell

env:
- IMAGE_NAME="${DOCKER_ORG}/geospaas"

services:
- docker

if: type != pull_request
# Environment variables defined as part of the Travis CI repository configuration are:
# - DOCKER_ORG: the docker hub organization (or user) to which the image will be pushed
# - DOCKER_USER: the docker hub user used to log in to the docker hub
# - DOCKER_PASS: the password of this user
# - PYPI_TOKEN: the token associated to the pypi account for deployment. More information can be found here: https://pypi.org/help/#apitoken
# - COVERALLS_REPO_TOKEN: authentication token for coveralls.io

install:
- docker pull $IMAGE_NAME || true
- docker build --cache-from $IMAGE_NAME . -t $IMAGE_NAME
env:
global:
- IMAGE_NAME="${DOCKER_ORG}/geospaas"

script:
- >
docker run --rm
-e COVERALLS_REPO_TOKEN
-e "TRAVIS=true"
-e TRAVIS_JOB_ID
-e TRAVIS_BRANCH
-e TRAVIS_PULL_REQUEST
-v "$(pwd):/src"
$IMAGE_NAME
bash -c "source /opt/conda/bin/activate && coverage run --omit=geospaas/nansat_ingestor/tests/*,geospaas/catalog/tests/*,geospaas/vocabularies/tests/* runtests.py && coveralls"
jobs:
include:
- stage: 'Unit tests'
if: type = push
env:
- TEST_IMAGE="${IMAGE_NAME}:latest"
install:
- docker pull "${TEST_IMAGE}" || true
script:
- >
docker run --rm
-e COVERALLS_REPO_TOKEN
-e "TRAVIS=true"
-e TRAVIS_JOB_ID
-e TRAVIS_BRANCH
-e TRAVIS_PULL_REQUEST
-v "$(pwd):/src"
${TEST_IMAGE}
bash -c "source /opt/conda/bin/activate && coverage run --omit=geospaas/nansat_ingestor/tests/*,geospaas/catalog/tests/*,geospaas/vocabularies/tests/* runtests.py && coveralls"
deploy:
- provider: pypi
user: "__token__"
password: "${PYPI_TOKEN}"
on:
tags: true

before_deploy:
- docker login -u $DOCKER_USER -p $DOCKER_PASS
- stage: 'Build Docker images'
name: 'Build standard image'
if: type = push
env:
- TAG='latest'
install:
- docker pull "${IMAGE_NAME}:${TAG}" || true
- >
docker build .
--cache-from "${IMAGE_NAME}:${TAG}"
--build-arg BASE_IMAGE="nansencenter/nansat:${TAG}"
-t "${IMAGE_NAME}:tmp"
before_deploy:
- docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
deploy:
- provider: script
on:
tags: true
script: /bin/bash scripts/docker_push.sh $TRAVIS_TAG latest

deploy:
- provider: script
on:
tags: true
script: /bin/bash scripts/docker_push.sh $TRAVIS_TAG latest
- provider: pypi
user: "__token__"
password: "${PYPI_TOKEN}"
on:
tags: true
- name: 'Build slim image'
if: type = push
env:
- TAG='latest-slim'
install:
- docker pull "${IMAGE_NAME}:${TAG}" || true
- >
docker build .
--cache-from "${IMAGE_NAME}:${TAG}"
--build-arg BASE_IMAGE="nansencenter/nansat:${TAG}"
-t "${IMAGE_NAME}:tmp"
before_deploy:
- docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
deploy:
- provider: script
on:
tags: true
script: /bin/bash scripts/docker_push.sh "${TRAVIS_TAG}-slim" 'latest-slim'
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
# Initialize from docker image with Python, libraries and Nansat
FROM nansencenter/nansat:latest
ARG BASE_IMAGE='nansencenter/nansat:latest'
FROM ${BASE_IMAGE}
LABEL purpose="Running and developing Django-Geo-SpaaS"
ENV PYTHONUNBUFFERED=1

# Install Django
RUN pip install \
RUN apt update \
&& apt install -y \
# psycopg2 dependencies
g++ \
libpq5 \
libpq-dev \
&& pip install \
bs4 \
coverage \
django==3.0.6 \
django-forms-bootstrap==3.1.0 \
django-leaflet==0.26.0 \
psycopg2==2.8.4 \
thredds_crawler==1.5.4 \
&& apt remove -y g++ && apt autoremove -y \
&& apt clean && rm -rf /var/lib/apt/lists/* \
&& echo "alias ll='ls -lh'" >> /root/.bashrc

# install Geo-SPaaS
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker_push.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
for tag in $*;do
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:${tag}"
docker tag "${IMAGE_NAME}:tmp" "${IMAGE_NAME}:${tag}"
docker push "${IMAGE_NAME}:${tag}"
done

0 comments on commit 48f0e2d

Please sign in to comment.