Add docker-cross todo cross build of docker image
This commit is contained in:
parent
4094407aac
commit
a733d828c3
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -60,6 +60,9 @@ coverage.all
|
|||
/integrations/pgsql.ini
|
||||
/node_modules
|
||||
|
||||
# Docker (cross build)
|
||||
/docker/Dockerfile.*
|
||||
/docker/qemu-*-static
|
||||
|
||||
# Snapcraft
|
||||
snap/.snapcraft/
|
||||
|
|
10
Dockerfile
10
Dockerfile
|
@ -1,8 +1,9 @@
|
|||
|
||||
ARG target=library
|
||||
###################################
|
||||
#Build stage
|
||||
FROM golang:1.10-alpine3.7 AS build-env
|
||||
|
||||
ARG GOARCH
|
||||
ARG GITEA_VERSION
|
||||
ARG TAGS="sqlite"
|
||||
ENV TAGS "bindata $TAGS"
|
||||
|
@ -16,11 +17,16 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
|
|||
|
||||
#Checkout version if set
|
||||
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
|
||||
&& go env \
|
||||
&& make clean generate build
|
||||
|
||||
FROM alpine:3.7
|
||||
###################################
|
||||
#Final build
|
||||
FROM $target/alpine:3.7
|
||||
LABEL maintainer="maintainers@gitea.io"
|
||||
|
||||
#QEMU phase
|
||||
|
||||
EXPOSE 22 3000
|
||||
|
||||
RUN apk --no-cache add \
|
||||
|
|
30
docker/Makefile
vendored
30
docker/Makefile
vendored
|
@ -1,8 +1,17 @@
|
|||
#Makefile related to docker
|
||||
|
||||
QEMU_VERSION ?= v2.11.0
|
||||
QEMU_ARCH ?= amd64
|
||||
GOARCH ?= amd64
|
||||
TARGET ?= library
|
||||
|
||||
DOCKER_IMAGE ?= gitea/gitea
|
||||
DOCKER_TAG ?= latest
|
||||
DOCKER_PLATFORM ?= $(shell docker version -f {{.Server.Os}}-{{.Server.Arch}} 2>/dev/null || echo 'undefined')
|
||||
ifneq ($(TARGET), library)
|
||||
DOCKER_PLATFORM ?= linux-$(GOARCH)
|
||||
else
|
||||
DOCKER_PLATFORM ?= $(shell docker version -f {{.Server.Os}}-{{.Server.Arch}} 2>/dev/null || echo 'undefined')
|
||||
endif
|
||||
DOCKER_REF ?= $(DOCKER_IMAGE):$(DOCKER_TAG)-$(DOCKER_PLATFORM)
|
||||
|
||||
.PHONY: docker
|
||||
|
@ -13,3 +22,22 @@ docker:
|
|||
.PHONY: docker-build
|
||||
docker-build:
|
||||
docker run -ti --rm -v $(CURDIR):/srv/app/src/code.gitea.io/gitea -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" webhippie/golang:edge make clean generate build
|
||||
|
||||
.PHONY: docker-cross
|
||||
docker-cross : docker-setup-qemu
|
||||
docker build --build-arg target=$(TARGET) --build-arg GOARCH=$(GOARCH) -f docker/Dockerfile.$(QEMU_ARCH) -t $(DOCKER_REF) .
|
||||
#exemple TARGET=arm64v8 GOARCH=arm64 QEMU_ARCH=aarch64 make docker-cross
|
||||
#exemple TARGET=amd64 GOARCH=amd64 QEMU_ARCH=amd64 make docker-cross
|
||||
#exemple TARGET=arm32v6 GOARCH=arm QEMU_ARCH=arm make docker-cross
|
||||
|
||||
TARGET: arm32v6
|
||||
.PHONY: docker-setup-qemu
|
||||
docker-setup-qemu:
|
||||
@if [ "$(QEMU_ARCH)" != "amd64" ]; then \
|
||||
echo "Loading qemu libs for multi-arch support."; \
|
||||
(cd docker && curl -sL https://github.com/multiarch/qemu-user-static/releases/download/${QEMU_VERSION}/qemu-${QEMU_ARCH}-static.tar.gz | tar xz); \
|
||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset; \
|
||||
sed "s/^#QEMU phase/COPY docker\/qemu-${QEMU_ARCH}-static* \/usr\/bin\//g" Dockerfile > docker/Dockerfile.${QEMU_ARCH}; \
|
||||
sed -i "s/make clean generate build/make build/g" docker/Dockerfile.${QEMU_ARCH}; \
|
||||
else cp Dockerfile docker/Dockerfile.${QEMU_ARCH}; \
|
||||
fi;
|
||||
|
|
Loading…
Reference in New Issue
Block a user