Skip to content

Commit

Permalink
Support multiarch (#107)
Browse files Browse the repository at this point in the history
* Remove old dockerfiles to avoid confusion

* Moving Dockerfiles to scripts directory

* Add newline between  badges and table of contents

* Updating Makefile to output 'subspace'

- Updating .gitignore for this too

* remove '-linux-amd64' from binary name

* Better layer caching and call 'make build'

* reduce layer size by removing apt cache

* Updating for new web/cmd directories

* Call make build in Dockerfile

* Fixing bindata removal

* ADD: Multiple tags

* Update multi-arch-manifest.yaml

Co-authored-by: Adrián González Barbosa <[email protected]>
Co-authored-by: jack1902 <[email protected]>
  • Loading branch information
3 people authored Jul 14, 2020
1 parent 7027ea8 commit 83ba088
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 117 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ARG BUILD_VERSION=unknown

ENV GODEBUG="netdns=go http2server=0"

RUN make BUILD_VERSION=${BUILD_VERSION}
RUN make build BUILD_VERSION=${BUILD_VERSION}

FROM alpine:3.11.6
LABEL maintainer="github.com/subspacecommunity/subspace"
Expand Down
23 changes: 0 additions & 23 deletions Dockerfile.build

This file was deleted.

25 changes: 17 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
all: subspace
.DEFAULT_GOAL := help
.PHONY: help

BUILD_VERSION?=unknown

subspace:
go run github.com/kevinburke/go-bindata/go-bindata -o cmd/subspace/bindata.go --prefix "web/" --pkg main web/... \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -v --compiler gc --ldflags "-extldflags -static -s -w -X main.version=${BUILD_VERSION}" -o subspace ./cmd/subspace

clean:
rm -f subspace cmd/subspace/bindata.go
help: ## Display this help message and exit
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build: clean ## Build the binary
@echo "Creating bindata.go..."
@go run github.com/kevinburke/go-bindata/go-bindata -o cmd/subspace/bindata.go --prefix "web/" --pkg main web/...
@echo "+++ bindata.go created"

.PHONY: clean
@echo "Compiling subspace..."
@CGO_ENABLED=0 \
go build -v --compiler gc --ldflags "-extldflags -static -s -w -X main.version=${BUILD_VERSION}" -o subspace ./cmd/subspace \
&& rm cmd/subspace/bindata.go
@echo "+++ subspace compiled"

clean: ## Remove old binaries
rm -f subspace cmd/subspace/bindata.go
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=subspacecommunity_subspace&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=subspacecommunity_subspace)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=subspacecommunity_subspace&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=subspacecommunity_subspace)


- [Subspace - A simple WireGuard VPN server GUI](#subspace---a-simple-wireguard-vpn-server-gui)
- [Slack](#slack)
- [Screenshots](#screenshots)
Expand Down
1 change: 1 addition & 0 deletions multi-arch-manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
image: subspacecommunity/subspace
tags: ['1.1.1', '1.1', '1']
manifests:
- image: subspacecommunity/subspace:amd64
platform:
Expand Down
24 changes: 10 additions & 14 deletions 386.dockerfile → scripts/dockerfiles/386.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,23 @@ WORKDIR /src
COPY Makefile ./
# go.mod and go.sum if exists
COPY go.* ./
COPY *.go ./
COPY static ./static
COPY templates ./templates
COPY email ./email
COPY cmd/ ./cmd
COPY web ./web

ARG BUILD_VERSION=unknown
ARG GOARCH=386

ENV GODEBUG="netdns=go http2server=0"

RUN make BUILD_VERSION=${BUILD_VERSION} GOARCH=${GOARCH}
RUN make build BUILD_VERSION=${BUILD_VERSION}

FROM i386/alpine:3.11.6
LABEL maintainer="github.com/subspacecommunity/subspace"

# Add QEMU
COPY --from=builder qemu-aarch64-static /usr/bin

LABEL maintainer="github.com/subspacecommunity/subspace"

COPY --from=build /src/subspace-linux-amd64 /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

ENV DEBIAN_FRONTEND noninteractive

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

RUN apk add --no-cache \
iproute2 \
iptables \
Expand All @@ -55,6 +45,12 @@ RUN apk add --no-cache \
wireguard-tools \
runit

COPY --from=build /src/subspace /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

ENTRYPOINT ["/usr/local/bin/entrypoint.sh" ]

CMD [ "/sbin/my_init" ]
21 changes: 9 additions & 12 deletions amd64.dockerfile → scripts/dockerfiles/amd64.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,20 @@ WORKDIR /src
COPY Makefile ./
# go.mod and go.sum if exists
COPY go.* ./
COPY *.go ./
COPY static ./static
COPY templates ./templates
COPY email ./email
COPY cmd/ ./cmd
COPY web ./web

ARG BUILD_VERSION=unknown
ARG GOARCH=amd64

ENV GODEBUG="netdns=go http2server=0"

RUN make BUILD_VERSION=${BUILD_VERSION} GOARCH=${GOARCH}
RUN make build BUILD_VERSION=${BUILD_VERSION}

FROM alpine:3.11.6
LABEL maintainer="github.com/subspacecommunity/subspace"

COPY --from=build /src/subspace-linux-amd64 /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

ENV DEBIAN_FRONTEND noninteractive

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

RUN apk add --no-cache \
iproute2 \
iptables \
Expand All @@ -41,6 +32,12 @@ RUN apk add --no-cache \
wireguard-tools \
runit

COPY --from=build /src/subspace /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

ENTRYPOINT ["/usr/local/bin/entrypoint.sh" ]

CMD [ "/sbin/my_init" ]
31 changes: 15 additions & 16 deletions arm32v5.dockerfile → scripts/dockerfiles/arm32v5.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,23 @@ WORKDIR /src
COPY Makefile ./
# go.mod and go.sum if exists
COPY go.* ./
COPY *.go ./
COPY static ./static
COPY templates ./templates
COPY email ./email
COPY cmd/ ./cmd
COPY web ./web

ARG BUILD_VERSION=unknown
ARG GOARCH=arm
ENV GOARM=5

ENV GODEBUG="netdns=go http2server=0"

RUN make BUILD_VERSION=${BUILD_VERSION} GOARCH=${GOARCH}
RUN make build BUILD_VERSION=${BUILD_VERSION}


FROM arm32v5/debian:buster-backports
# Add QEMU
COPY --from=builder qemu-arm-static /usr/bin

LABEL maintainer="github.com/subspacecommunity/subspace"

COPY --from=build /src/subspace-linux-amd64 /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

ENV DEBIAN_FRONTEND noninteractive

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init
# Add QEMU
COPY --from=builder qemu-arm-static /usr/bin

RUN apt-get update \
&& apt-get install -y \
Expand All @@ -54,7 +44,16 @@ RUN apt-get update \
dnsmasq \
socat \
wireguard-tools \
runit
runit \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /src/subspace /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

ENV DEBIAN_FRONTEND noninteractive

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

ENTRYPOINT ["/usr/local/bin/entrypoint.sh" ]

Expand Down
25 changes: 11 additions & 14 deletions arm32v6.dockerfile → scripts/dockerfiles/arm32v6.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,25 @@ WORKDIR /src
COPY Makefile ./
# go.mod and go.sum if exists
COPY go.* ./
COPY *.go ./
COPY static ./static
COPY templates ./templates
COPY email ./email
COPY cmd/ ./cmd
COPY web ./web

ARG BUILD_VERSION=unknown
ARG GOARCH=arm
ENV GOARM=6

ENV GODEBUG="netdns=go http2server=0"

RUN make BUILD_VERSION=${BUILD_VERSION} GOARCH=${GOARCH}
RUN make build BUILD_VERSION=${BUILD_VERSION}


FROM arm32v6/alpine:3.11.6
# Add QEMU
COPY --from=builder qemu-arm-static /usr/bin

LABEL maintainer="github.com/subspacecommunity/subspace"

COPY --from=build /src/subspace-linux-amd64 /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init
# Add QEMU
COPY --from=builder qemu-arm-static /usr/bin

ENV DEBIAN_FRONTEND noninteractive

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

RUN apk add --no-cache \
iproute2 \
iptables \
Expand All @@ -54,6 +45,12 @@ RUN apk add --no-cache \
wireguard-tools \
runit

COPY --from=build /src/subspace /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

ENTRYPOINT ["/usr/local/bin/entrypoint.sh" ]

CMD [ "/sbin/my_init" ]
24 changes: 10 additions & 14 deletions arm32v7.dockerfile → scripts/dockerfiles/arm32v7.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,24 @@ WORKDIR /src
COPY Makefile ./
# go.mod and go.sum if exists
COPY go.* ./
COPY *.go ./
COPY static ./static
COPY templates ./templates
COPY email ./email
COPY cmd/ ./cmd
COPY web ./web

ARG BUILD_VERSION=unknown
ARG GOARCH=arm
ENV GOARM=7

ENV GODEBUG="netdns=go http2server=0"

RUN make BUILD_VERSION=${BUILD_VERSION} GOARCH=${GOARCH}
RUN make build BUILD_VERSION=${BUILD_VERSION}

FROM arm32v7/alpine:3.11.6
LABEL maintainer="github.com/subspacecommunity/subspace"

# Add QEMU
COPY --from=builder qemu-arm-static /usr/bin

LABEL maintainer="github.com/subspacecommunity/subspace"

COPY --from=build /src/subspace-linux-amd64 /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

ENV DEBIAN_FRONTEND noninteractive

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

RUN apk add --no-cache \
iproute2 \
iptables \
Expand All @@ -56,6 +46,12 @@ RUN apk add --no-cache \
wireguard-tools \
runit

COPY --from=build /src/subspace /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

ENTRYPOINT ["/usr/local/bin/entrypoint.sh" ]

CMD [ "/sbin/my_init" ]
24 changes: 10 additions & 14 deletions arm64v8.dockerfile → scripts/dockerfiles/arm64v8.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,23 @@ WORKDIR /src
COPY Makefile ./
# go.mod and go.sum if exists
COPY go.* ./
COPY *.go ./
COPY static ./static
COPY templates ./templates
COPY email ./email
COPY cmd/ ./cmd
COPY web ./web

ARG BUILD_VERSION=unknown
ARG GOARCH=arm64

ENV GODEBUG="netdns=go http2server=0"

RUN make BUILD_VERSION=${BUILD_VERSION} GOARCH=${GOARCH}
RUN make build BUILD_VERSION=${BUILD_VERSION}

FROM arm64v8/alpine:3.11.6
LABEL maintainer="github.com/subspacecommunity/subspace"

# Add QEMU
COPY --from=builder qemu-aarch64-static /usr/bin

LABEL maintainer="github.com/subspacecommunity/subspace"

COPY --from=build /src/subspace-linux-amd64 /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

ENV DEBIAN_FRONTEND noninteractive

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

RUN apk add --no-cache \
iproute2 \
iptables \
Expand All @@ -55,6 +45,12 @@ RUN apk add --no-cache \
wireguard-tools \
runit

COPY --from=build /src/subspace /usr/bin/subspace
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY bin/my_init /sbin/my_init

RUN chmod +x /usr/bin/subspace /usr/local/bin/entrypoint.sh /sbin/my_init

ENTRYPOINT ["/usr/local/bin/entrypoint.sh" ]

CMD [ "/sbin/my_init" ]

0 comments on commit 83ba088

Please sign in to comment.