faster docker build
This commit is contained in:
parent
1d20137c27
commit
b45652b305
4 changed files with 20 additions and 10 deletions
24
Dockerfile
24
Dockerfile
|
|
@ -2,21 +2,31 @@ FROM golang:1.18-stretch as builder
|
||||||
|
|
||||||
ARG VER=devel
|
ARG VER=devel
|
||||||
|
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
|
|
||||||
|
# thanks to https://github.com/montanaflynn/golang-docker-cache
|
||||||
|
RUN mkdir -p /cache/crypto
|
||||||
|
COPY crypto /cache/crypto
|
||||||
|
COPY go.mod go.sum /cache/
|
||||||
|
WORKDIR /cache
|
||||||
|
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
|
||||||
|
|
||||||
RUN mkdir -p /out/plugins
|
RUN mkdir -p /out/plugins
|
||||||
ADD . /src/
|
ADD . /src/
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
RUN CGO_ENABLED=0 go build -o /out -ldflags "-X main.mainver=$VER" ./cmd/...
|
RUN go build -o /out -ldflags "-X main.mainver=$VER" ./cmd/...
|
||||||
RUN CGO_ENABLED=0 go build -o /out/plugins -ldflags "-X main.mainver=$VER" ./plugin/...
|
RUN go build -o /out/plugins -ldflags "-X main.mainver=$VER" ./plugin/...
|
||||||
|
|
||||||
FROM busybox
|
FROM busybox
|
||||||
LABEL maintainer="Boshi Lian<farmer1992@gmail.com>"
|
LABEL maintainer="Boshi Lian<farmer1992@gmail.com>"
|
||||||
|
|
||||||
|
COPY --from=ep76/openssh-static:latest /usr/bin/ssh-keygen /bin/ssh-keygen
|
||||||
RUN mkdir /etc/ssh/
|
RUN mkdir /etc/ssh/
|
||||||
|
RUN mkdir /sshpiperd
|
||||||
|
|
||||||
ADD entrypoint.sh /
|
ADD entrypoint.sh /sshpiperd
|
||||||
COPY --from=builder /out/ /
|
COPY --from=builder /out/ /sshpiperd
|
||||||
COPY --from=ep76/openssh-static:latest /usr/bin/ssh-keygen /ssh-keygen
|
|
||||||
EXPOSE 2222
|
EXPOSE 2222
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/sshpiperd/entrypoint.sh"]
|
||||||
CMD ["/sshpiperd", "/plugins/workingdir"]
|
CMD ["/sshpiperd/sshpiperd", "/sshpiperd/plugins/workingdir"]
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ sudo ./out/sshpiperd --log-level=trace ./out/simplemath -- ./out/fixed --target
|
||||||
|
|
||||||
Plugin list
|
Plugin list
|
||||||
|
|
||||||
* [workingdir](plugin/workingdir/) 🔀: ask for working directory before login, demo purpose
|
* [workingdir](plugin/workingdir/) 🔀: `/home`-like directory to managed upstreams routing by sshpiped.
|
||||||
* [azdevicecode](plugin/azdevicecode/) 🔒: ask user to enter [azure device code](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code) before login
|
* [azdevicecode](plugin/azdevicecode/) 🔒: ask user to enter [azure device code](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code) before login
|
||||||
* [fixed](plugin/fixed/) 🔀: fixed targetting the dummy sshd server
|
* [fixed](plugin/fixed/) 🔀: fixed targetting the dummy sshd server
|
||||||
* [simplemath](plugin/simplemath/) 🔒: ask for very simple math question before login, demo purpose
|
* [simplemath](plugin/simplemath/) 🔒: ask for very simple math question before login, demo purpose
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ set -euo pipefail
|
||||||
|
|
||||||
|
|
||||||
if [ ! -f /etc/ssh/ssh_host_rsa_key ];then
|
if [ ! -f /etc/ssh/ssh_host_rsa_key ];then
|
||||||
/ssh-keygen -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key
|
ssh-keygen -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Working Directory plugin for sshpiperd
|
# Working Directory plugin for sshpiperd
|
||||||
|
|
||||||
`Working Dir` is a `/home`-like directory.
|
`Working Dir` is a `/home`-like directory.
|
||||||
SSHPiperd read files from `workingdir/[username]/` to know upstream's configuration.
|
sshpiperd read files from `workingdir/[username]/` to know upstream's configuration.
|
||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue