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.
This commit is contained in:
Masco Skray 2019-04-18 22:20:16 +08:00
parent 2565c18256
commit e0914a8f31
2 changed files with 8 additions and 1 deletions

View File

@ -1,10 +1,11 @@
FROM ubuntu:18.04
MAINTAINER MascoSkray <MascoSkray@gmail.com>
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\

View File

@ -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" .