-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
23 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
.git/ | ||
build/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
.DS_Store | ||
build/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
FROM --platform=$BUILDPLATFORM golang:1.13.0-alpine3.10 AS build | ||
ARG TARGETPLATFORM | ||
ARG VERSION | ||
WORKDIR /go/src/github.com/robbertkl/docker-ipv6nat | ||
COPY . . | ||
RUN [ "$TARGETPLATFORM" = "linux/amd64" ] && echo GOOS=linux GOARCH=amd64 > .env || true | ||
RUN [ "$TARGETPLATFORM" = "linux/arm64" ] && echo GOOS=linux GOARCH=arm64 > .env || true | ||
RUN [ "$TARGETPLATFORM" = "linux/arm/v6" ] && echo GOOS=linux GOARCH=arm GOARM=6 > .env || true | ||
RUN [ "$TARGETPLATFORM" = "linux/arm/v7" ] && echo GOOS=linux GOARCH=arm GOARM=7 > .env || true | ||
ENV CGO_ENABLED=0 | ||
RUN env $(cat .env | xargs) go build -o /docker-ipv6nat -ldflags "-X main.buildVersion=$VERSION" ./cmd/docker-ipv6nat | ||
RUN env $(cat .env | xargs) go build -o /docker-ipv6nat.$(echo "$TARGETPLATFORM" | sed -E 's/(^linux|\/)//g') ./cmd/docker-ipv6nat | ||
|
||
FROM alpine:3.10 AS release | ||
RUN apk add --no-cache ip6tables | ||
COPY --from=build /docker-ipv6nat / | ||
COPY --from=build /docker-ipv6nat.* /docker-ipv6nat | ||
COPY docker-ipv6nat-compat / | ||
ENTRYPOINT ["/docker-ipv6nat-compat"] | ||
CMD ["--retry"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
#!/bin/sh | ||
|
||
cd `dirname "${0}"` | ||
|
||
VERSION="${1}" | ||
BUILDER=ipv6nat-builder | ||
PLATFORMS="linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7" | ||
BUILD_DIR=build | ||
DIST_DIR=dist | ||
VERSION="${1}" | ||
|
||
if [ -z "${VERSION}" ] | ||
then | ||
echo "Usage: ${0} X.X.X" | ||
exit 1 | ||
fi | ||
|
||
DOCKER_TLS_VERIFY= | ||
DOCKER_HOST= | ||
DOCKER_CERT_PATH= | ||
DOCKER_MACHINE_NAME= | ||
DOCKER_VERSION="system" | ||
|
||
cd `dirname "${0}"` | ||
|
||
set -e | ||
set -x | ||
|
||
docker buildx rm "${BUILDER}" || true | ||
docker buildx create --name "${BUILDER}" --use | ||
docker buildx build \ | ||
--platform "${PLATFORMS}" \ | ||
--platform "linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7" \ | ||
--pull \ | ||
--build-arg "VERSION=${VERSION}" \ | ||
--output "type=local,dest=${BUILD_DIR}" \ | ||
--push | ||
--push \ | ||
--tag "robbertkl/ipv6nat:${VERSION}" \ | ||
--tag "robbertkl/ipv6nat:latest" \ | ||
. | ||
|
||
BUILDER_CONTAINER="buildx_buildkit_${BUILDER}0" | ||
docker exec "${BUILDER_CONTAINER}" sh -c \ | ||
'mkdir /dist; mv /var/lib/buildkit/runc-overlayfs/snapshots/snapshots/*/fs/docker-ipv6nat.* /dist' | ||
rm -Rf "${DIST_DIR}/" | ||
docker cp "${BUILDER_CONTAINER}:/dist" "${DIST_DIR}" | ||
|
||
docker buildx use default | ||
docker buildx rm "${BUILDER}" | ||
|
||
mkdir -p "${DIST_DIR}" | ||
for PLATFORM in `echo "${PLATFORMS}" | sed 's/,/ /g'` | ||
do | ||
PLATFORM_BUILD_DIR="${BUILD_DIR}/`echo "${PLATFORM}" | sed -E 's/\//_/g'`" | ||
PLATFORM_TAG="`echo "${PLATFORM}" | sed -E 's/(^linux|\/)//g'`" | ||
mv "${PLATFORM_BUILD_DIR}/docker-ipv6nat" "${DIST_DIR}/docker-ipv6nat.${PLATFORM_TAG}" | ||
done | ||
rm -Rf "${BUILD_DIR}/" |