Skip to content

Commit

Permalink
Merge branch 'tag_tgf_image_info_in_dockerfile'
Browse files Browse the repository at this point in the history
* tag_tgf_image_info_in_dockerfile:
  Add more specific criteria for tgf image name to determine if the environment variables should be injected.
  Tag the tgf image info directly in the Dockerfiles
  • Loading branch information
jocgir committed Feb 15, 2018
2 parents 460b432 + b6721ec commit b9aaba4
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Dockerfile.0.Base
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ ARG EXT=_linux_64-bits.zip
LABEL vendor="Coveo"
LABEL maintainer "[email protected]"

ENV TGF_IMAGE="coveo/tgf"
ENV TGF_IMAGE_TAG="base"
ENV TGF_IMAGE_VERSION="${TRAVIS_TAG}"
ENV TGF_IMAGE_MAJ_MIN="${TRAVIS_TAG_MAJ_MIN}"

RUN apk update && \
apk add openssl ca-certificates libc6-compat curl rsync && \
adduser -D tgf && \
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ARG EXT=_linux_64-bits.zip
LABEL vendor="Coveo"
LABEL maintainer "[email protected]"

ENV TGF_IMAGE_TAG=""

# Install Shells
RUN apk update && apk add bash zsh fish bash-completion

Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.2.AWS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ARG EXT=_linux_64-bits.zip
LABEL vendor="Coveo"
LABEL maintainer "[email protected]"

ENV TGF_IMAGE_TAG="aws"

# Update version here (do not move at the beginning of the file since it would slow down the docker build)
RUN TF_AWS=1.9.0-coveo.0 && curl -sLo_ https://github.com/coveo/terraform-provider-aws/releases/download/v${TF_AWS}/terraform-provider-aws_${TF_AWS}${EXT} && unzip -p _ > ${EXE_FOLDER}/terraform-provider-aws && \
chmod +x $EXE_FOLDER/* && rm _
2 changes: 2 additions & 0 deletions Dockerfile.2.K8S
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ ARG EXE_FOLDER=/usr/local/bin
LABEL vendor="Coveo"
LABEL maintainer "[email protected]"

ENV TGF_IMAGE_TAG="k8s"

# Install ssh (Required to perform port forwarding through bastion)
RUN apk add openssh git

Expand Down
5 changes: 5 additions & 0 deletions Dockerfile.3.Full
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ FROM ubuntu:latest
LABEL vendor="Coveo"
LABEL maintainer "[email protected]"

ENV TGF_IMAGE="coveo/tgf"
ENV TGF_IMAGE_TAG="full"
ENV TGF_IMAGE_VERSION="${TRAVIS_TAG}"
ENV TGF_IMAGE_MAJ_MIN="${TRAVIS_TAG_MAJ_MIN}"

ARG DEBIAN_FRONTEND=noninteractive
ARG EXE_FOLDER=/usr/local/bin
ARG EXT=_linux_64-bits.zip
Expand Down
21 changes: 12 additions & 9 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,22 @@ func callDocker(args ...string) int {

config.Environment["TGF_COMMAND"] = config.EntryPoint
config.Environment["TGF_VERSION"] = version
config.Environment["TGF_IMAGE"] = config.Image
config.Environment["TGF_ARGS"] = strings.Join(os.Args, " ")
config.Environment["TGF_LAUNCH_FOLDER"] = sourceFolder
if config.ImageVersion != nil {
config.Environment["TGF_IMAGE_VERSION"] = *config.ImageVersion
if version, err := semver.Make(*config.ImageVersion); err == nil {
config.Environment["TGF_MAJ_MIN"] = fmt.Sprintf("%d.%d", version.Major, version.Minor)
config.Environment["TGF_IMAGE_NAME"] = imageName // sha256 of image

if !strings.Contains(config.Image, "coveo/tgf") { // the tgf image injects its own image info
config.Environment["TGF_IMAGE"] = config.Image
if config.ImageVersion != nil {
config.Environment["TGF_IMAGE_VERSION"] = *config.ImageVersion
if version, err := semver.Make(*config.ImageVersion); err == nil {
config.Environment["TGF_IMAGE_MAJ_MIN"] = fmt.Sprintf("%d.%d", version.Major, version.Minor)
}
}
if config.ImageTag != nil {
config.Environment["TGF_IMAGE_TAG"] = *config.ImageTag
}
}
if config.ImageTag != nil {
config.Environment["TGF_IMAGE_TAG"] = *config.ImageTag
}
config.Environment["TGF_IMAGE_NAME"] = imageName

for key, val := range config.Environment {
os.Setenv(key, val)
Expand Down
2 changes: 2 additions & 0 deletions make_dockers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ do
tag=${tag,,}
[ -z ${tag} ] || tag=-${tag}
travis_tag=${TRAVIS_TAG:6}
travis_maj_min=${travis_tag%.*}
version=coveo/tgf:${travis_tag}${tag}
latest=${tag:1}
latest=coveo/tgf:${latest:-latest}
Expand All @@ -26,6 +27,7 @@ do
# We replace the TRAVIS_TAG variable if any (case where the image is build from another image)
# The result file is simply named Dockerfile
cat $df | sed -e "s/\${TRAVIS_TAG}/$travis_tag/" > $dockerfile
cat $df | sed -e "s/\${TRAVIS_TAG_MAJ_MIN}/$travis_maj_min/" > $dockerfile

docker build -f $dockerfile -t $version . && rm $dockerfile
docker push $version
Expand Down

0 comments on commit b9aaba4

Please sign in to comment.