dockamole/client/Dockerfile

48 lines
1.1 KiB
Docker
Raw Permalink Normal View History

2019-08-09 23:38:50 +00:00
ARG REPO=library
# Build mole for all arch
FROM golang:1.12-alpine AS builder
2019-06-24 21:44:08 +00:00
2020-01-11 00:11:40 +00:00
RUN apk add --no-cache git~=2.24 curl~=7.67 tar~=1.32
2019-08-09 23:38:50 +00:00
RUN mkdir /app
2020-01-11 00:11:40 +00:00
ENV MOLE_VERSION=0.4.0
2019-11-12 17:59:21 +00:00
RUN curl -L "https://github.com/davrodpin/mole/archive/v${MOLE_VERSION}.tar.gz" | tar zx -C /app
2019-08-09 23:38:50 +00:00
WORKDIR /app/mole-${MOLE_VERSION}
# Download dependencies so they can be cached
RUN go mod download
# Build static
ARG GOARCH=amd64
ENV CGO_ENABLED=0 GOOS=linux
2019-11-12 17:59:21 +00:00
RUN go build -a -ldflags "-X main.version=${MOLE_VERSION}-dockamole" -installsuffix nocgo -o /bin/mole github.com/davrodpin/mole/cmd/mole
2019-08-09 23:38:50 +00:00
# Build client image using target arch
2019-11-12 17:59:21 +00:00
FROM multiarch/qemu-user-static:4.1.0-1 as qemu-user-static
FROM ${REPO}/alpine:3.9
2019-08-09 23:38:50 +00:00
# Make multiarch capable
2019-11-12 17:59:21 +00:00
COPY --from=qemu-user-static /usr/bin/qemu-* /usr/bin/
2019-08-09 23:38:50 +00:00
# Copy mole from builder
COPY --from=builder /bin/mole /usr/bin/mole
2019-11-12 17:59:21 +00:00
RUN apk --no-cache add bash=4.4.19-r1 openssh-client=7.9_p1-r6
2019-06-24 19:46:33 +00:00
RUN mkdir /mole
RUN adduser -S -h /mole mole
USER mole
RUN mkdir -p /mole/.ssh
RUN touch /mole/.ssh/config
# Make a volume to persist keys
VOLUME /mole/.ssh
2019-11-12 17:59:21 +00:00
# Generate known hosts on first connect
ENV GEN_KNOWN_HOSTS=1
2019-06-24 19:46:33 +00:00
COPY ./start.sh ./
CMD ./start.sh