From e0914a8f31141a6321607f2ad2234644d0d4cda6 Mon Sep 17 00:00:00 2001 From: Masco Skray Date: Thu, 18 Apr 2019 22:20:16 +0800 Subject: [PATCH] chore(install/bundle): let Dockerfile get current branch when building Previous the branch in Dockerfile is specified manually in each branch. But when someone want to change the branch or test they must modify it. To make the process more intelligent, we will auto get the branch name. And, to make the image smaller, we added --single-branch argument onto. --- install/bundle/Dockerfile | 3 ++- install/bundle/hooks/build | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 install/bundle/hooks/build diff --git a/install/bundle/Dockerfile b/install/bundle/Dockerfile index cfa24b2..f7e1b82 100644 --- a/install/bundle/Dockerfile +++ b/install/bundle/Dockerfile @@ -1,10 +1,11 @@ FROM ubuntu:18.04 MAINTAINER MascoSkray +ARG CLONE_ADDFLAG #Update apt and install git RUN apt-get update && apt-get install -y git #Clone the latest UOJ Community verison to local -RUN cd ~ && git clone https://github.com/UniversalOJ/UOJ-System.git --depth 1 +RUN cd ~ && git clone https://github.com/UniversalOJ/UOJ-System.git --depth 1 --single-branch ${CLONE_ADDFLAG} #Install environment and set startup script RUN cd ~/UOJ-System/install/bundle && sh install.sh -p && echo "\ #!/bin/sh\n\ diff --git a/install/bundle/hooks/build b/install/bundle/hooks/build new file mode 100644 index 0000000..63e2605 --- /dev/null +++ b/install/bundle/hooks/build @@ -0,0 +1,6 @@ +#!/bin/sh +CLONE_ADDFLAG="-b $DOCKER_TAG" +if [ "$DOCKER_TAG" = "latest" ]; then + CLONE_ADDFLAG="-b master" +fi +docker build -t $IMAGE_NAME --build-arg CLONE_ADDFLAG="$CLONE_ADDFLAG" .