Skip to content

Commit 7ce01cb

Browse files
committed
Fix push script
1 parent 6a96709 commit 7ce01cb

File tree

6 files changed

+23
-25
lines changed

6 files changed

+23
-25
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
.git/
2-
build/
32
dist/

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
.DS_Store
2-
build/
32
dist/

.release-it.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"hooks": {
3+
"before:bump": "sed -E -i '' 's/^const buildVersion = .*$/const buildVersion = \"${version}\"/' cmd/docker-ipv6nat/main.go",
34
"after:bump": "./push.sh ${version}",
45
"after:release": "rm -Rf dist/"
56
},

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
FROM --platform=$BUILDPLATFORM golang:1.13.0-alpine3.10 AS build
22
ARG TARGETPLATFORM
3-
ARG VERSION
43
WORKDIR /go/src/github.com/robbertkl/docker-ipv6nat
54
COPY . .
65
RUN [ "$TARGETPLATFORM" = "linux/amd64" ] && echo GOOS=linux GOARCH=amd64 > .env || true
76
RUN [ "$TARGETPLATFORM" = "linux/arm64" ] && echo GOOS=linux GOARCH=arm64 > .env || true
87
RUN [ "$TARGETPLATFORM" = "linux/arm/v6" ] && echo GOOS=linux GOARCH=arm GOARM=6 > .env || true
98
RUN [ "$TARGETPLATFORM" = "linux/arm/v7" ] && echo GOOS=linux GOARCH=arm GOARM=7 > .env || true
109
ENV CGO_ENABLED=0
11-
RUN env $(cat .env | xargs) go build -o /docker-ipv6nat -ldflags "-X main.buildVersion=$VERSION" ./cmd/docker-ipv6nat
10+
RUN env $(cat .env | xargs) go build -o /docker-ipv6nat.$(echo "$TARGETPLATFORM" | sed -E 's/(^linux|\/)//g') ./cmd/docker-ipv6nat
1211

1312
FROM alpine:3.10 AS release
1413
RUN apk add --no-cache ip6tables
15-
COPY --from=build /docker-ipv6nat /
14+
COPY --from=build /docker-ipv6nat.* /docker-ipv6nat
1615
COPY docker-ipv6nat-compat /
1716
ENTRYPOINT ["/docker-ipv6nat-compat"]
1817
CMD ["--retry"]

cmd/docker-ipv6nat/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"github.com/robbertkl/docker-ipv6nat"
1111
)
1212

13-
var (
14-
buildVersion string
13+
const buildVersion = "0.3.8"
1514

15+
var (
1616
cleanup bool
1717
retry bool
1818
userlandProxy bool

push.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
#!/bin/sh
22

3-
cd `dirname "${0}"`
4-
5-
VERSION="${1}"
63
BUILDER=ipv6nat-builder
7-
PLATFORMS="linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7"
8-
BUILD_DIR=build
94
DIST_DIR=dist
5+
VERSION="${1}"
106

117
if [ -z "${VERSION}" ]
128
then
139
echo "Usage: ${0} X.X.X"
1410
exit 1
1511
fi
1612

13+
DOCKER_TLS_VERIFY=
14+
DOCKER_HOST=
15+
DOCKER_CERT_PATH=
16+
DOCKER_MACHINE_NAME=
17+
DOCKER_VERSION="system"
18+
19+
cd `dirname "${0}"`
20+
1721
set -e
1822
set -x
1923

2024
docker buildx rm "${BUILDER}" || true
2125
docker buildx create --name "${BUILDER}" --use
2226
docker buildx build \
23-
--platform "${PLATFORMS}" \
27+
--platform "linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7" \
2428
--pull \
25-
--build-arg "VERSION=${VERSION}" \
26-
--output "type=local,dest=${BUILD_DIR}" \
27-
--push
29+
--push \
2830
--tag "robbertkl/ipv6nat:${VERSION}" \
2931
--tag "robbertkl/ipv6nat:latest" \
3032
.
33+
34+
BUILDER_CONTAINER="buildx_buildkit_${BUILDER}0"
35+
docker exec "${BUILDER_CONTAINER}" sh -c \
36+
'mkdir /dist; mv /var/lib/buildkit/runc-overlayfs/snapshots/snapshots/*/fs/docker-ipv6nat.* /dist'
37+
rm -Rf "${DIST_DIR}/"
38+
docker cp "${BUILDER_CONTAINER}:/dist" "${DIST_DIR}"
39+
3140
docker buildx use default
3241
docker buildx rm "${BUILDER}"
33-
34-
mkdir -p "${DIST_DIR}"
35-
for PLATFORM in `echo "${PLATFORMS}" | sed 's/,/ /g'`
36-
do
37-
PLATFORM_BUILD_DIR="${BUILD_DIR}/`echo "${PLATFORM}" | sed -E 's/\//_/g'`"
38-
PLATFORM_TAG="`echo "${PLATFORM}" | sed -E 's/(^linux|\/)//g'`"
39-
mv "${PLATFORM_BUILD_DIR}/docker-ipv6nat" "${DIST_DIR}/docker-ipv6nat.${PLATFORM_TAG}"
40-
done
41-
rm -Rf "${BUILD_DIR}/"

0 commit comments

Comments
 (0)