Skip to content

Commit

Permalink
Merge pull request yuki-kimoto#171 from alpha6/docker_builder
Browse files Browse the repository at this point in the history
Using temporary container to build dependencies
  • Loading branch information
yuki-kimoto authored Sep 24, 2021
2 parents 8e16d9a + 197b75d commit dcdea59
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.9
FROM alpine:3.9 as BUILDER

# Update OS and install dependencies
RUN set -x \
Expand All @@ -9,32 +9,16 @@ RUN set -x \
bash \
shadow \
perl \
git \
openssh-server \
perl-dev \
gcc \
g++ \
curl \
wget \
make

# Create user gitprep
RUN set -x \
&& useradd -m gitprep \
&& mkdir -m 700 /home/gitprep/.ssh \
&& usermod -p '*' gitprep \
&& touch /home/gitprep/.ssh/authorized_keys \
&& chmod 600 /home/gitprep/.ssh/authorized_keys \
&& chown -R gitprep:gitprep /home/gitprep/.ssh \
&& sed -i 's/#PasswordAuthentication yes.*/PasswordAuthentication no/' /etc/ssh/sshd_config \
&& sed -i 's/#ChallengeResponseAuthentication yes.*/ChallengeResponseAuthentication no /' /etc/ssh/sshd_config

USER gitprep

# Install GitPrep
RUN set -x \
&& git --version \
&& perl -v \
&& mkdir -m 700 /home/gitprep \
&& curl -kL https://github.com/yuki-kimoto/gitprep/archive/latest.tar.gz \
> /home/gitprep/gitprep-latest.tar.gz \
&& mkdir /home/gitprep/gitprep \
Expand All @@ -46,17 +30,31 @@ RUN set -x \
&& prove t \
&& ./setup_database

USER root
FROM alpine:3.9

# Clean obsolete Packages
RUN set -x \
&& apk del --no-cache \
perl-dev \
gcc \
g++ \
curl \
wget \
make
&& apk update \
&& apk upgrade \
&& apk --no-cache add \
tini \
bash \
shadow \
perl \
git \
openssh-server

# Create user gitprep
RUN set -x \
&& useradd -m gitprep \
&& mkdir -p -m 700 /home/gitprep/.ssh \
&& usermod -p '*' gitprep \
&& touch /home/gitprep/.ssh/authorized_keys \
&& chmod 600 /home/gitprep/.ssh/authorized_keys \
&& chown -R gitprep:gitprep /home/gitprep/.ssh \
&& sed -i 's/#PasswordAuthentication yes.*/PasswordAuthentication no/' /etc/ssh/sshd_config \
&& sed -i 's/#ChallengeResponseAuthentication yes.*/ChallengeResponseAuthentication no /' /etc/ssh/sshd_config

COPY --chown=gitprep:gitprep --from=BUILDER /home/gitprep/gitprep /home/gitprep/gitprep

# Copy start script
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
Expand Down

0 comments on commit dcdea59

Please sign in to comment.