-
Notifications
You must be signed in to change notification settings - Fork 3
Add Dockerfile and Dockertag generation from templates #12
Conversation
build-all.bash
Outdated
|
||
RELEASE_HASH=$(curl -s https://api.github.com/repos/iterative/dvc/releases/latest | sha256sum | cut -c -8) | ||
./generate-all.bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why create a separate generate-all.bash
yet not use it anywhere else? Either keep things in one file or re-use them in multiple places, surely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this call to generate-all.bash
. For debugging and security, generate
, build
, push
should be called separately IMO.
|
||
ARG RELEASE_HASH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove? (also same with all other similar cases...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because these are set by environment variables now, with envsubst
in generate.bash
. Previously RELEASE_HASH
was supplied as --build-arg
in docker build
. ARG
in Dockerfile
is misleading.
LGTM in general, I didn't check the code behind it though. I hope @casperdcl did this :) |
Why does CI fail? |
will need a second pass - I suggested obvious fixes in case that helps with CI |
CI fails because of missing Docker username/password in PR. I removed run in PR from GA. I'll test it afterward. |
It looks the scripts are running as expected. I run
and all images are generated and pushed. I'll run these containers, test a few commands if they work and push containers to |
I'll add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably use the GH interface (https://github.com/iterative/dvc-doc-containers/pull/12/files) to respond to reviews (including e.g. "add suggestion to batch" functionality to commit changes)
# pull_request: | ||
# branches: [ master ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: revert
- | ||
name: Generate containers from templates | ||
run: ./generate-all.bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
appropriately named one-line run command makes name meaningless (same for the cases below)
- | |
name: Generate containers from templates | |
run: ./generate-all.bash | |
- run: ./generate-all.bash |
dockerdir=$(dirname "${filepath}") | ||
tagfile="${dockerdir}/Dockertag" | ||
if [ -f "${tagfile}" ] ; then | ||
TAG=$(head -n 1 "${tagfile}") | ||
else | ||
TAG=$(echo "${dockerdir:3:100}" | tr '/ ' '--') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dockerdir=$(dirname "${filepath}") | |
tagfile="${dockerdir}/Dockertag" | |
if [ -f "${tagfile}" ] ; then | |
TAG=$(head -n 1 "${tagfile}") | |
else | |
TAG=$(echo "${dockerdir:3:100}" | tr '/ ' '--') | |
dockerdir="$(dirname "${filepath}")" | |
tagfile="${dockerdir}/Dockertag" | |
if [ -f "${tagfile}" ] ; then | |
TAG="$(head -n 1 "${tagfile}")" | |
else | |
TAG="$(echo "${dockerdir:3:100}" | tr '/ ' '--')" |
HERE="$( cd "$(dirname "$0")" ; pwd -P )" | ||
export TAG_PREFIX="${TAG_PREFIX:-dvcorg}" | ||
|
||
find . -name generate.* | sort | while read -r filepath ; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find . -name generate.* | sort | while read -r filepath ; do | |
find . -name 'generate.*' | sort | while read -r filepath ; do |
filename=$(basename -- "$filepath") | ||
dirname=$(dirname -- "$filepath") | ||
ext="${filename##*.}" | ||
pushd $dirname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filename=$(basename -- "$filepath") | |
dirname=$(dirname -- "$filepath") | |
ext="${filename##*.}" | |
pushd $dirname | |
filename="$(basename -- "$filepath")" | |
dirname="$(dirname -- "$filepath")" | |
ext="${filename##*.}" | |
pushd "$dirname" |
find ${HERE} -name Dockerfile.template | sort | while read -r filepath ; do | ||
ABSOLUTE_SOURCE=$(dirname "$filepath") | ||
SOURCE_DIR=$(realpath --relative-to="${HERE}" "${ABSOLUTE_SOURCE}") | ||
TARGET_DIR="${HERE}/build/${SOURCE_DIR}" | ||
if [ ! -d "${TARGET_DIR}" ] ; then | ||
mkdir -p "${TARGET_DIR}" | ||
fi | ||
cp -fr ${ABSOLUTE_SOURCE}/* "${TARGET_DIR}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find ${HERE} -name Dockerfile.template | sort | while read -r filepath ; do | |
ABSOLUTE_SOURCE=$(dirname "$filepath") | |
SOURCE_DIR=$(realpath --relative-to="${HERE}" "${ABSOLUTE_SOURCE}") | |
TARGET_DIR="${HERE}/build/${SOURCE_DIR}" | |
if [ ! -d "${TARGET_DIR}" ] ; then | |
mkdir -p "${TARGET_DIR}" | |
fi | |
cp -fr ${ABSOLUTE_SOURCE}/* "${TARGET_DIR}" | |
find "${HERE}" -name Dockerfile.template | sort | while read -r filepath ; do | |
ABSOLUTE_SOURCE="$(dirname "$filepath")" | |
SOURCE_DIR="$(realpath --relative-to="${HERE}" "${ABSOLUTE_SOURCE}")" | |
TARGET_DIR="${HERE}/build/${SOURCE_DIR}" | |
if [ ! -d "${TARGET_DIR}" ] ; then | |
mkdir -p "${TARGET_DIR}" | |
fi | |
cp -fr "${ABSOLUTE_SOURCE}"/* "${TARGET_DIR}" |
dockerdir=$(dirname "${filepath}") | ||
tagfile="${dockerdir}/Dockertag" | ||
if [ -f "${tagfile}" ] ; then | ||
TAG=$(head -n 1 "${tagfile}") | ||
else | ||
TAG=$(echo "${dockerdir:3:100}" | tr '/ ' '--') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dockerdir=$(dirname "${filepath}") | |
tagfile="${dockerdir}/Dockertag" | |
if [ -f "${tagfile}" ] ; then | |
TAG=$(head -n 1 "${tagfile}") | |
else | |
TAG=$(echo "${dockerdir:3:100}" | tr '/ ' '--') | |
dockerdir="$(dirname "${filepath}")" | |
tagfile="${dockerdir}/Dockertag" | |
if [ -f "${tagfile}" ] ; then | |
TAG="$(head -n 1 "${tagfile}")" | |
else | |
TAG="$(echo "${dockerdir:3:100}" | tr '/ ' '--')" |
@@ -1,28 +1,25 @@ | |||
FROM ubuntu:20.04 | |||
FROM python:3.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- does the katacode base have to be changed as well?
- should this be slim?
FROM python:3.8 | |
FROM python:3.8-slim |
|
||
if [[ -d build ]] ; then | ||
echo "Please delete ${PWD}/build directory first." | ||
exit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit | |
exit 1 |
|
||
export GIT_TAG="${TAG}" | ||
|
||
git clone build/dvc-get-started -b "${GIT_TAG}" "${TAG_DIR}/dvc-get-started" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git clone build/dvc-get-started -b "${GIT_TAG}" "${TAG_DIR}/dvc-get-started" | |
git clone "file://$PWD/build/dvc-get-started/.git" -b "${GIT_TAG}" "${TAG_DIR}/dvc-get-started" |
This PR is a major update for the Docker image production.
Divided
build-all.bash
into two (build-all.bash
andpush-all.bash
) and addedgenerate-all.bash
that generatesDockerfile
s fromDockerfile.template
files.Instead of static
Dockerfile
andDockertag
s, the script first generates a set ofDockerfile
andDockertag
s by callinggenerate.*
scripts in directories.generate.*
scripts can be written inbash
,sh
,zsh
, orpython
.generate-all.bash
checks the extension ofgenerate.EXT
script and calls the appropriate interpreter.RELEASE_HASH
andTAG_PREFIX
can be set before calling the script now. Hence runningproduces a set of
Dockertag
files usingmy_docker_username/
Docker handle.DVC Get Started Images
These images are produced by
start/generate.bash
For each Git tag in
dvc-get-started
, aDockerfile
-Dockertag
pair is generated instart/build/
.Dockerfile
s are all depend topython:3.8
public Docker image.Dockertag
files use${TAG_PREFIX}/doc-start:${GIT_TAG}
format. For prefixdvcorg
, and Git tagsignal-file
, the produced Docker image is tagged asdvcorg/doc-start:signal-file
Katacoda Image changes
Formerly Katacoda images were produced from static files. In this version, these are also converted to
Dockerfile.template
files and generated usingTAG_PREFIX
variable. In the previous version,Dockerfile
s hadFROM dvcorg/doc-katacoda:base
lines. In this version, these are replaced byFROM ${TAG_PREFIX}/doc-katacoda:base
, so when the user changes${TAG_PREFIX}
, they also change dependencies amongDockerfile
s. This allows for third parties to use these images in their own Dockerhub (or other repository) accounts.Closes #7
Closes #11
Related iterative/example-repos-dev#34