Add multi-arch targets
This commit is contained in:
parent
e377ab4586
commit
a46ee33b97
53
Makefile
53
Makefile
@ -1,3 +1,6 @@
|
||||
DOCKER_TAG := dockamole
|
||||
MOLE_VERSION := 0.4.0
|
||||
|
||||
.PHONY: default
|
||||
default: server client
|
||||
|
||||
@ -45,5 +48,53 @@ keys/etc/ssh/ssh_host_dsa_key: keys
|
||||
keys/etc/ssh/ssh_host_ecdsa_key: keys
|
||||
keys/etc/ssh/ssh_host_ed25519_key: keys
|
||||
keys/etc/ssh/ssh_host_rsa_key: keys
|
||||
|
||||
keys/known_hosts: keys
|
||||
|
||||
# Build images
|
||||
|
||||
.PHONY: build
|
||||
build: build-client build-server
|
||||
|
||||
.PHONY: build-client
|
||||
build-client:
|
||||
docker build client -t $(DOCKER_TAG)-client
|
||||
|
||||
.PHONY: build-server
|
||||
build-server:
|
||||
docker build server -t $(DOCKER_TAG)-server
|
||||
|
||||
.PHONY: build-arm32v6
|
||||
build-arm32v6: build-client-arm32v6 build-server-arm32v6
|
||||
|
||||
.PHONY: build-client-arm32v6
|
||||
build-client-arm32v6:
|
||||
docker build client --build-arg REPO=arm32v6 --build-arg GOARCH=arm -t $(DOCKER_TAG)-client-arm32v6
|
||||
|
||||
.PHONY: build-server-arm32v6
|
||||
build-server-arm32v6:
|
||||
docker build server --build-arg REPO=arm32v6 -t $(DOCKER_TAG)-server-arm32v6
|
||||
|
||||
.PHONY: build-arm32v7
|
||||
build-arm32v7: build-client-arm32v7 build-server-arm32v7
|
||||
|
||||
.PHONY: build-client-arm32v7
|
||||
build-client-arm32v7:
|
||||
docker build client --build-arg REPO=arm32v7 --build-arg GOARCH=arm -t $(DOCKER_TAG)-client-arm32v7
|
||||
|
||||
.PHONY: build-server-arm32v7
|
||||
build-server-arm32v7:
|
||||
docker build server --build-arg REPO=arm32v7 -t $(DOCKER_TAG)-server-arm32v7
|
||||
|
||||
.PHONY: build-arm64v8
|
||||
build-arm64v8: build-client-arm64v8 build-server-arm64v8
|
||||
|
||||
.PHONY: build-client-arm64v8
|
||||
build-client-arm64v8:
|
||||
docker build client --build-arg REPO=arm64v8 --build-arg GOARCH=arm64 -t $(DOCKER_TAG)-client-arm64v8
|
||||
|
||||
.PHONY: build-server-arm64v8
|
||||
build-server-arm64v8:
|
||||
docker build server --build-arg REPO=arm64v8 -t $(DOCKER_TAG)-server-arm64v8
|
||||
|
||||
.PHONY: build-all
|
||||
build-all: build build-arm32v6 build-arm64v8
|
||||
|
@ -1,9 +1,32 @@
|
||||
FROM alpine
|
||||
ARG REPO=library
|
||||
# Build mole for all arch
|
||||
FROM golang:1.12-alpine AS builder
|
||||
|
||||
# Install latest mole
|
||||
RUN apk --no-cache add bash curl tar openssh-client && \
|
||||
bash -c "bash <(curl -fsSL https://raw.githubusercontent.com/davrodpin/mole/master/tools/install.sh | sed 's/\bsudo\b//g')" && \
|
||||
apk del curl tar
|
||||
ENV MOLE_VERSION=0.4.0
|
||||
|
||||
RUN apk add --no-cache git curl tar
|
||||
|
||||
RUN mkdir /app
|
||||
RUN curl -L https://github.com/davrodpin/mole/archive/v${MOLE_VERSION}.tar.gz | tar zx -C /app
|
||||
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
|
||||
RUN go build -a -ldflags '-X main.version=${MOLE_VERSION}-dockamole' -installsuffix nocgo -o /bin/mole github.com/davrodpin/mole/cmd/mole
|
||||
|
||||
# Build client image using target arch
|
||||
FROM ${REPO}/alpine
|
||||
|
||||
# Make multiarch capable
|
||||
COPY --from=multiarch/qemu-user-static /usr/bin/qemu-* /usr/bin/
|
||||
# Copy mole from builder
|
||||
COPY --from=builder /bin/mole /usr/bin/mole
|
||||
|
||||
RUN apk --no-cache add bash openssh-client
|
||||
|
||||
RUN mkdir /mole
|
||||
RUN adduser -S -h /mole mole
|
||||
|
@ -1,4 +1,10 @@
|
||||
FROM alpine
|
||||
ARG REPO=library
|
||||
FROM multiarch/qemu-user-static AS qemu
|
||||
|
||||
# Build image from alpine
|
||||
FROM ${REPO}/alpine
|
||||
|
||||
COPY --from=qemu /usr/bin/qemu-* /usr/bin/
|
||||
|
||||
# Install SSH and set up basic config
|
||||
RUN apk add openssh-server augeas
|
||||
|
Loading…
Reference in New Issue
Block a user