0123456789101112131415161718192021222324252627282930313233343536373839404142
|
FROM golang:alpine as build
RUN apk update
RUN apk upgrade
RUN apk add --no-cache build-base
COPY . /app
WORKDIR /app
ARG version
RUN VERSION=$version make build
FROM alpine:latest
RUN apk update
RUN apk upgrade
RUN apk add --no-cache git openssh
COPY --from=build /app/bin /app/bin
RUN ln -s /app/bin/goit-shell /usr/local/bin/goit-shell
RUN addgroup -g 973 -S git
RUN adduser -g git -s /bin/sh -G git -S -u 973 git
RUN sed -i 's/^git:!:/git:*:/' /etc/shadow
RUN mkdir -p /home/git/.config /home/git/.local/share /home/git/.local/state
RUN chown -R git:git /home/git/.config /home/git/.local
RUN sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
RUN echo 'HostKey /etc/ssh/host_keys/etc/ssh/ssh_host_rsa_key' >> /etc/ssh/sshd_config.d/00_host_keys.conf
RUN echo 'HostKey /etc/ssh/host_keys/etc/ssh/ssh_host_ecdsa_key' >> /etc/ssh/sshd_config.d/00_host_keys.conf
RUN echo 'HostKey /etc/ssh/host_keys/etc/ssh/ssh_host_ed25519_key' >> /etc/ssh/sshd_config.d/00_host_keys.conf
WORKDIR /app
EXPOSE 8080/tcp
EXPOSE 22/tcp
# VOLUME /home/git/.config/goit /home/git/.local/share/goit /home/git/.local/state/goit
VOLUME /etc/ssh/host_keys
RUN cat <<EOF > /app/bin/launch.sh
#!/bin/sh -e
mkdir -p /etc/ssh/host_keys/etc/ssh
ssh-keygen -A -f /etc/ssh/host_keys
/usr/sbin/sshd -D &
su git -c "/app/bin/goit \$@"
EOF
ENTRYPOINT ["sh", "/app/bin/launch.sh"]
|