Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and release to dockerhub #8

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ jobs:
script: make travis-pr-build
- stage: "Test"
script: make travis-pr-test
- stage: "Docker publish"
script: ./publish.sh
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
FROM python:3.6-alpine3.9 as builder
FROM python:3.6-alpine3.12 as builder

COPY . work
WORKDIR /work

RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
apk update && apk upgrade && \
apk add --no-cache --virtual build-dependencies build-base && \
apk add --no-cache librdkafka-dev@edge~=1.1.0 && \
pip install --install-option="--prefix=/install" . && \
apk add --no-cache librdkafka-dev@edge~=1.4 && \
pip install --prefix=/install --no-warn-script-location . && \
apk del build-dependencies

FROM python:3.6-alpine3.9
FROM python:3.6-alpine3.12


ENV HOME=/home/pyrandall

RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
apk update && apk upgrade && \
apk add --no-cache librdkafka@edge~=1.1.0 && \
apk add --no-cache librdkafka@edge~=1.4 && \
apk add ca-certificates && rm -rf /var/cache/apk/* && \
addgroup -S -g 1000 pyrandall && \
adduser -D -S -u 1000 -G pyrandall -h $HOME pyrandall
Expand Down
19 changes: 19 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
DOCKER_IMAGE=pyrandall
GIT_SHORT_SHA=$(git rev-parse --short HEAD)
GIT_REF_NAME=$(git rev-parse --abbrev-ref HEAD)

VERSION=$(<VERSION)
DOCKER_TAG="${DOCKER_IMAGE}:${VERSION}-${GIT_SHORT_SHA}"

if [ "$GIT_REF_NAME" = "master" ]
then
# Tag existing as stable release (without git-short-sha)
docker tag "${DOCKER_TAG}" "${DOCKER_IMAGE}:${VERSION}"
docker tag "${DOCKER_TAG}" "${DOCKER_IMAGE}:master"
# TODO: login and publish to dockerhub
else
# Build new image and tag
docker build -t "${DOCKER_TAG}" .
docker tag "${DOCKER_TAG}" "${DOCKER_IMAGE}:latest"
# TODO: login and publish to dockerhub
fi