Update staged build with versioning and targets

This commit is contained in:
IamTheFij 2019-08-14 10:40:19 -07:00
parent 7af52c54b1
commit c9374f5e83
2 changed files with 32 additions and 9 deletions

View File

@ -10,7 +10,10 @@ COPY ./go.mod ./go.sum /app/
RUN go mod download RUN go mod download
COPY ./main.go /app/ COPY ./main.go /app/
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -a -installsuffix nocgo -o dockron . ARG ARCH=amd64
ARG VERSION=dev
ENV CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH}
RUN go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo -o dockron .
FROM ${REPO}/busybox:latest FROM ${REPO}/busybox:latest
WORKDIR /root/ WORKDIR /root/

View File

@ -66,12 +66,12 @@ docker-build:
docker build . -t ${DOCKER_TAG}-linux-amd64 docker build . -t ${DOCKER_TAG}-linux-amd64
# Cross build for arm architechtures # Cross build for arm architechtures
.PHONY: docker-cross-build-arm .PHONY: docker-build-arm
docker-cross-build-arm: docker-build-arm:
docker build --build-arg REPO=arm32v7 --build-arg ARCH=arm . -t ${DOCKER_TAG}-linux-arm docker build --build-arg REPO=arm32v7 --build-arg ARCH=arm . -t ${DOCKER_TAG}-linux-arm
.PHONY: docker-cross-build-arm .PHONY: docker-build-arm
docker-cross-build-arm64: docker-build-arm64:
docker build --build-arg REPO=arm64v8 --build-arg ARCH=arm64 . -t ${DOCKER_TAG}-linux-arm64 docker build --build-arg REPO=arm64v8 --build-arg ARCH=arm64 . -t ${DOCKER_TAG}-linux-arm64
.PHONY: docker-run .PHONY: docker-run
@ -79,10 +79,30 @@ docker-run: docker-build
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run $(DOCKER_TAG)-linux-amd64 docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run $(DOCKER_TAG)-linux-amd64
# Cross run on host architechture # Cross run on host architechture
.PHONY: docker-cross-run-arm .PHONY: docker-run-arm
docker-cross-run-arm: docker-cross-build-arm docker-run-arm: docker-build-arm
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run ${DOCKER_TAG}-linux-arm docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run ${DOCKER_TAG}-linux-arm
.PHONY: docker-cross-run-arm64 .PHONY: docker-run-arm64
docker-cross-run-arm64: docker-cross-build-arm64 docker-run-arm64: docker-build-arm64
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run ${DOCKER_TAG}-linux-arm64 docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name $(DOCKER_TAG)-run ${DOCKER_TAG}-linux-arm64
# Multi stage builds
.PHONY: docker-staged-build
docker-staged-build:
docker build --build-arg VERSION=${VERSION} \
-t ${DOCKER_TAG}-linux-amd64 \
-f Dockerfile.multi-stage .
# Cross build for arm architechtures
.PHONY: docker-staged-build-arm
docker-staged-build-arm:
docker build --build-arg VERSION=${VERSION} \
--build-arg REPO=arm32v7 --build-arg ARCH=arm -t ${DOCKER_TAG}-linux-arm \
-f Dockerfile.multi-stage .
.PHONY: docker-staged-build-arm
docker-staged-build-arm64:
docker build --build-arg VERSION=${VERSION} \
--build-arg REPO=arm64v8 --build-arg ARCH=arm64 -t ${DOCKER_TAG}-linux-arm64 \
-f Dockerfile.multi-stage .