From 079098eedd6fa9685675b021569a333c0db769ba Mon Sep 17 00:00:00 2001 From: Filipe Santos Date: Sun, 22 Apr 2018 16:53:37 +1200 Subject: [PATCH] Add docker build by branch --- .dockerignore | 23 ----------------------- docker/.dockerignore | 2 ++ Dockerfile => docker/Dockerfile | 11 +++++------ docker/hooks/build | 3 +++ 4 files changed, 10 insertions(+), 29 deletions(-) delete mode 100644 .dockerignore create mode 100644 docker/.dockerignore rename Dockerfile => docker/Dockerfile (85%) create mode 100644 docker/hooks/build diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index e2c9e06..0000000 --- a/.dockerignore +++ /dev/null @@ -1,23 +0,0 @@ -# Git -.git - -# Systemd files -systemd - -# Logs -*.log* - -# Configs -*.json - -# Byte-compiled / optimized / DLL files -**/__pycache__ -*.py[cod] -*$py.class -*.pyc - -# Pyenv -**/.python-version - -# User-specific stuff: -.idea diff --git a/docker/.dockerignore b/docker/.dockerignore new file mode 100644 index 0000000..bfefeee --- /dev/null +++ b/docker/.dockerignore @@ -0,0 +1,2 @@ +# Hooks +hooks diff --git a/Dockerfile b/docker/Dockerfile similarity index 85% rename from Dockerfile rename to docker/Dockerfile index 3034b41..2bc7543 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -1,13 +1,12 @@ FROM python:3.6-alpine3.7 +# Default branch to master +ARG BRANCH=master + ENV \ - # App directory APP_DIR=traktarr \ - # Branch to clone - BRANCH=master \ - # Config file + BRANCH=${BRANCH} \ TRAKTARR_CONFIG=/config/config.json \ - # Log file TRAKTARR_LOGFILE=/config/traktarr.log RUN \ @@ -15,7 +14,7 @@ RUN \ apk --no-cache -U upgrade && \ echo "** Install OS dependencies **" && \ apk --no-cache -U add git && \ - echo "** Get Traktarr **" && \ + echo "** Get Traktarr branch: ${BRANCH} **" && \ git clone --depth 1 --branch ${BRANCH} https://github.com/l3uddz/traktarr.git /${APP_DIR} && \ echo "** Install PIP dependencies **" && \ pip install --no-cache-dir --upgrade pip setuptools && \ diff --git a/docker/hooks/build b/docker/hooks/build new file mode 100644 index 0000000..a6ef3df --- /dev/null +++ b/docker/hooks/build @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build --build-arg BRANCH=${SOURCE_BRANCH} -f ${DOCKERFILE_PATH} -t ${IMAGE_NAME} .