Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
#39 simplufy docker build
Browse files Browse the repository at this point in the history
Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>
  • Loading branch information
evidolob committed Feb 7, 2019
1 parent 76230eb commit 5c1bf54
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
3 changes: 1 addition & 2 deletions build_and_push_docker_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ for image_dir in "${DOCKER_FILES_LOCATIONS[@]}"
do
if [ "$image_dir" == "dockerfiles/theia" ]; then
THEIA_IMAGE_TAG="$(awk '/ARG THEIA_VERSION=/{print $NF}' dockerfiles/theia/Dockerfile | cut -d '=' -f2)-nightly"
bash $(pwd)/$image_dir/build.sh --build-arg:GITHUB_TOKEN=${GITHUB_TOKEN}
bash $(pwd)/$image_dir/build.sh --build-args:GITHUB_TOKEN=${GITHUB_TOKEN},THEIA_VERSION=master --name:theia-master
bash $(pwd)/$image_dir/build.sh --build-args:GITHUB_TOKEN=${GITHUB_TOKEN},THEIA_VERSION=master --branch:master --git-ref:refs\\/heads\\/master
elif [ "$image_dir" == "dockerfiles/theia-dev" ]; then
bash $(pwd)/$image_dir/build.sh --build-arg:GITHUB_TOKEN=${GITHUB_TOKEN}
else
Expand Down
10 changes: 9 additions & 1 deletion dockerfiles/build.include
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ init() {
BUILD_ARGS=""

PARENT_IMAGE=""
BRANCH=""
GIT_REF=""

while [ $# -gt 0 ]; do
case $1 in
Expand Down Expand Up @@ -84,6 +86,12 @@ init() {
BUILD_ARGS_CSV="${1#*:}"
prepare_build_args $BUILD_ARGS_CSV
shift ;;
--branch:*)
BRANCH="${1#*:}"
shift ;;
--git-ref:*)
GIT_REF="${1#*:}"
shift ;;
--*)
printf "${RED}Unknown parameter: $1${NC}\n"; exit 2 ;;
*)
Expand Down Expand Up @@ -130,7 +138,7 @@ build() {
build_image() {
printf "${BOLD}Building Docker Image ${IMAGE_NAME} from $DIR directory with tag $TAG${NC}\n"
# Replace macros in Dockerfiles
cat ${DIR}/${DOCKERFILE} | sed s/\$\{BUILD_ORGANIZATION\}/${ORGANIZATION}/ | sed s/\$\{BUILD_PREFIX\}/${PREFIX}/ | sed s/\$\{BUILD_TAG\}/${TAG}/ | sed s/\$\{BUILD_PARENT_IMAGE\}/${PARENT_IMAGE}/ > ${DIR}/.Dockerfile
cat ${DIR}/${DOCKERFILE} | sed s/\$\{BUILD_ORGANIZATION\}/${ORGANIZATION}/ | sed s/\$\{BUILD_PREFIX\}/${PREFIX}/ | sed s/\$\{BUILD_TAG\}/${TAG}/ | sed s/\$\{BUILD_PARENT_IMAGE\}/${PARENT_IMAGE}/ | sed s/\$\{GIT_BRANCH_NAME\}/${BRANCH}/ | sed s/\$\{GIT_REF\}/"${GIT_REF}"/ > ${DIR}/.Dockerfile
cd "${DIR}" && docker build -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} .
rm ${DIR}/.Dockerfile
if [ $? -eq 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/theia-dev/e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ FROM ${BUILD_ORGANIZATION}/${BUILD_PREFIX}-theia-dev:${BUILD_TAG}
ARG GITHUB_TOKEN

# Just try to build the latest theia with current image
RUN git clone -b 'v0.3.17' --single-branch --depth 1 https://github.com/theia-ide/theia theia
RUN git clone -b 'v0.3.19' --single-branch --depth 1 https://github.com/theia-ide/theia theia

This comment has been minimized.

Copy link
@benoitf

benoitf Feb 7, 2019

Contributor

just a comment about "one day improvement"
would be nice if we could extract version of theia automatically

RUN cd theia && yarn

16 changes: 8 additions & 8 deletions dockerfiles/theia/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ RUN if [ ! -z "${GITHUB_TOKEN-}" ]; then \
fi

#invalidate cashe
ADD https://${GITHUB_TOKEN}:x-oauth-basic@api.github.com/repos/theia-ide/theia/git/refs/heads/master /tmp/master.json
ADD https://${GITHUB_TOKEN}:x-oauth-basic@api.github.com/repos/theia-ide/theia/git/${GIT_REF} /tmp/master.json

# Clone theia
#RUN git clone --branch v${THEIA_VERSION} --single-branch --depth 1 https://github.com/theia-ide/theia ${HOME}/theia-source-code
RUN if [ $THEIA_VERSION == "master" ]; then \
echo "Cloning Theia master branch"; \
(git clone --branch master --single-branch --depth 1 https://github.com/theia-ide/theia ${HOME}/theia-source-code) ; \
else \
(git clone --branch v${THEIA_VERSION} --single-branch --depth 1 https://github.com/theia-ide/theia ${HOME}/theia-source-code); \
fi
RUN git clone --branch ${GIT_BRANCH_NAME} --single-branch --depth 1 https://github.com/theia-ide/theia ${HOME}/theia-source-code
# RUN if [ $THEIA_VERSION == "master" ]; then \

This comment has been minimized.

Copy link
@benoitf

benoitf Feb 7, 2019

Contributor

let's remove these comments ?

# echo "Cloning Theia master branch"; \
# (git clone --branch master --single-branch --depth 1 https://github.com/theia-ide/theia ${HOME}/theia-source-code) ; \
# else \
# (git clone --branch v${THEIA_VERSION} --single-branch --depth 1 https://github.com/theia-ide/theia ${HOME}/theia-source-code); \
# fi

# Add patches
ADD src/patches ${HOME}/patches
Expand Down

0 comments on commit 5c1bf54

Please sign in to comment.