-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Dockerfile
59 lines (50 loc) · 2.24 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM ruby:slim
LABEL org.opencontainers.image.authors="[email protected]"
# This is in order to have the man pages during exercises
RUN sed -i '/path-exclude \/usr\/share\/man/d' /etc/dpkg/dpkg.cfg.d/docker
RUN sed -i '/path-exclude \/usr\/share\/groff/d' /etc/dpkg/dpkg.cfg.d/docker
RUN apt update && apt install -y man git && apt install --reinstall coreutils
# The DATA_PATH is used for the deliverables, or the submissible
# content for the classroom activity.
ENV DATA_PATH="/data"
# The REPO_PATH is where the original or the teacher's forked repo
# resides inside the container.
ENV REPO_PATH="/root/githug"
# The LEVEL_PATH is where the current challenge resides and where
# students should navigate prior to attemping to use the `githug`
# commands.
ENV LEVEL_PATH="/git_hug"
ENV GITHUG_GITCONF="/root/.gitconfig"
ENV GITHUG_PROFILE="$LEVEL_PATH/.profile.yml"
ENV GITHUG_HISTORY_OUTPUT="$DATA_PATH/history.txt"
ENV GITHUG_PROFILE_OUTPUT="$DATA_PATH/profile.yml"
ENV GITHUG_GITCONF_OUTPUT="$DATA_PATH/gitconfig"
RUN mkdir -p $DATA_PATH
ADD . $REPO_PATH
WORKDIR $REPO_PATH
RUN gem build
RUN gem install *.gem
WORKDIR /
RUN echo "y" | $GEM_HOME/bin/githug
RUN cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT
WORKDIR $LEVEL_PATH
# The bash login script in below clears the history and restores
# progress using the contents of the $GITHUG_PROFILE_OUTPUT file.
RUN printf "history -c\nHISTSIZE= \nHISTFILESIZE= \n\
echo '--- NEW SESSION ---' >> $GITHUG_HISTORY_OUTPUT \n\
if ! [ -e $GITHUG_PROFILE_OUTPUT ]; then \n\
echo 'ERROR: Corrupt level progress data. Exiting.' \n\
echo '>>> CORRUPT DATA <<<' >> $GITHUG_HISTORY_OUTPUT \n\
exit 1; fi \n\
cp $GITHUG_GITCONF_OUTPUT $GITHUG_GITCONF \n\
mkdir -p $LEVEL_PATH && cp $GITHUG_PROFILE_OUTPUT $GITHUG_PROFILE \n\
export PATH=\"\$GEM_HOME/bin:\$PATH\" \n\
cd $LEVEL_PATH && githug reset \n\
echo -e '\nIMPORTANT: everything you type in this container is \
recorded to assist in the grading process.' \n" >> ~/.bash_profile
RUN printf "history -a\ncat \$HISTFILE >> $GITHUG_HISTORY_OUTPUT \n\
cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT \n\
cp $GITHUG_GITCONF $GITHUG_GITCONF_OUTPUT 2>/dev/null \n\
cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT \n" >> ~/.bash_logout
ENTRYPOINT ["/bin/bash", "--login"]
VOLUME $DATA_PATH