build: update docker build
This commit is contained in:
parent
7e91a47be8
commit
cace53a02b
|
@ -308,8 +308,8 @@ jobs:
|
||||||
env:
|
env:
|
||||||
PROFILE: ${{ matrix.profile}}
|
PROFILE: ${{ matrix.profile}}
|
||||||
run: |
|
run: |
|
||||||
if [ -d /tmp/packages/$PROFILE ]; then
|
if [ -d _packages/$PROFILE ]; then
|
||||||
cd /tmp/packages/$PROFILE
|
cd _packages/$PROFILE
|
||||||
for var in $(ls emqx-* ); do
|
for var in $(ls emqx-* ); do
|
||||||
bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"
|
bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"
|
||||||
done
|
done
|
||||||
|
@ -319,7 +319,7 @@ jobs:
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.profile }}
|
name: ${{ matrix.profile }}
|
||||||
path: /tmp/packages/${{ matrix.profile }}/.
|
path: _packages/${{ matrix.profile }}/.
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
@ -329,6 +329,8 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
profile: ${{fromJSON(needs.prepare.outputs.profiles)}}
|
profile: ${{fromJSON(needs.prepare.outputs.profiles)}}
|
||||||
|
otp:
|
||||||
|
- 23.3.4.8-1
|
||||||
arch:
|
arch:
|
||||||
- [amd64, x86_64]
|
- [amd64, x86_64]
|
||||||
- [arm64v8, aarch64]
|
- [arm64v8, aarch64]
|
||||||
|
@ -348,22 +350,42 @@ jobs:
|
||||||
path: .
|
path: .
|
||||||
- name: unzip source code
|
- name: unzip source code
|
||||||
run: unzip -q source.zip
|
run: unzip -q source.zip
|
||||||
- name: build emqx docker image
|
- uses: docker/setup-buildx-action@v1
|
||||||
env:
|
- uses: docker/setup-qemu-action@v1
|
||||||
PROFILE: ${{ matrix.profile }}
|
|
||||||
ARCH: ${{ matrix.arch[0] }}
|
|
||||||
QEMU_ARCH: ${{ matrix.arch[1] }}
|
|
||||||
run: |
|
|
||||||
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
||||||
|
|
||||||
cd source
|
|
||||||
sudo TARGET=emqx/$PROFILE ARCH=$ARCH QEMU_ARCH=$QEMU_ARCH make docker
|
|
||||||
cd _packages/$PROFILE && for var in $(ls ${PROFILE}-docker-* ); do sudo bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"; done && cd -
|
|
||||||
- uses: actions/upload-artifact@v1
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.profile }}
|
image: tonistiigi/binfmt:latest
|
||||||
path: source/_packages/${{ matrix.profile }}/.
|
platforms: all
|
||||||
|
- uses: docker/metadata-action@v3
|
||||||
|
id: meta
|
||||||
|
with:
|
||||||
|
images: ${{ github.repository_owner }}/${{ matrix.profile }}
|
||||||
|
flavor: |
|
||||||
|
latest=${{ !github.event.release.prerelease }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=ref,event=tag
|
||||||
|
type=semver,pattern={{version}}-otp${{ matrix.otp }}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}-otp${{ matrix.otp }}
|
||||||
|
- uses: docker/login-action@v1
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USER }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
- uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: ${{ github.event_name == 'release' }}
|
||||||
|
pull: true
|
||||||
|
no-cache: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
build-args: |
|
||||||
|
BUILD_FROM=ghcr.io/emqx/emqx-builder/4.4:${{ matrix.otp }}-alpine3.14
|
||||||
|
RUN_FROM=alpine:3.14
|
||||||
|
EMQX_NAME=${{ matrix.profile }}
|
||||||
|
file: source/deploy/docker/Dockerfile
|
||||||
|
context: source
|
||||||
|
|
||||||
delete-artifact:
|
delete-artifact:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
@ -443,15 +465,6 @@ jobs:
|
||||||
-X POST \
|
-X POST \
|
||||||
-d "{\"repo\":\"emqx/emqx\", \"tag\": \"${{ env.version }}\" }" \
|
-d "{\"repo\":\"emqx/emqx\", \"tag\": \"${{ env.version }}\" }" \
|
||||||
${{ secrets.EMQX_IO_RELEASE_API }}
|
${{ secrets.EMQX_IO_RELEASE_API }}
|
||||||
- name: push docker image to docker hub
|
|
||||||
if: github.event_name == 'release'
|
|
||||||
run: |
|
|
||||||
set -e -x -u
|
|
||||||
sudo make docker-prepare
|
|
||||||
cd _packages/${{ matrix.profile }} && for var in $(ls |grep docker |grep -v sha256); do unzip $var; sudo docker load < ${var%.*}; rm -f ${var%.*}; done && cd -
|
|
||||||
echo ${{ secrets.DOCKER_HUB_TOKEN }} |sudo docker login -u ${{ secrets.DOCKER_HUB_USER }} --password-stdin
|
|
||||||
sudo TARGET=emqx/${{ matrix.profile }} make docker-push
|
|
||||||
sudo TARGET=emqx/${{ matrix.profile }} make docker-manifest-list
|
|
||||||
- name: update repo.emqx.io
|
- name: update repo.emqx.io
|
||||||
if: github.event_name == 'release' && endsWith(github.repository, 'enterprise') && matrix.profile == 'emqx-ee'
|
if: github.event_name == 'release' && endsWith(github.repository, 'enterprise') && matrix.profile == 'emqx-ee'
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -10,14 +10,19 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
otp:
|
||||||
|
- 23.3.4.8-1
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
imgname: ${{ steps.build_docker.outputs.imgname}}
|
imgname: ${{ steps.prepare.outputs.imgname}}
|
||||||
version: ${{ steps.build_docker.outputs.version}}
|
version: ${{ steps.prepare.outputs.version}}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: build docker
|
- name: prepare
|
||||||
id: build_docker
|
id: prepare
|
||||||
run: |
|
run: |
|
||||||
if [ -f EMQX_ENTERPRISE ]; then
|
if [ -f EMQX_ENTERPRISE ]; then
|
||||||
echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
|
echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
|
||||||
|
@ -25,18 +30,20 @@ jobs:
|
||||||
echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token
|
echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token
|
||||||
make deps-emqx-ee
|
make deps-emqx-ee
|
||||||
make clean
|
make clean
|
||||||
fi
|
|
||||||
make docker
|
|
||||||
echo "::set-output name=version::$(./pkg-vsn.sh)"
|
|
||||||
if [ -f EMQX_ENTERPRISE ]; then
|
|
||||||
echo "::set-output name=imgname::emqx-ee"
|
echo "::set-output name=imgname::emqx-ee"
|
||||||
|
echo "::set-output name=version::$(./pkg-vsn.sh)"
|
||||||
else
|
else
|
||||||
echo "::set-output name=imgname::emqx"
|
echo "::set-output name=imgname::emqx"
|
||||||
|
echo "::set-output name=version::$(./pkg-vsn.sh)"
|
||||||
fi
|
fi
|
||||||
|
- name: build docker image
|
||||||
|
run: |
|
||||||
|
make ${{ steps.prepare.outputs.imgname }}-docker
|
||||||
|
docker save emqx/${{ steps.prepare.outputs.imgname }}:${{ steps.prepare.outputs.version }} -o image.tar.gz
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: emqx-docker-image-zip
|
name: image
|
||||||
path: _packages/${{ steps.build_docker.outputs.imgname }}/${{ steps.build_docker.outputs.imgname }}-docker-${{ steps.build_docker.outputs.version }}.zip
|
path: image.tar.gz
|
||||||
|
|
||||||
webhook:
|
webhook:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -52,15 +59,11 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: emqx-docker-image-zip
|
name: image
|
||||||
path: /tmp
|
path: /tmp
|
||||||
- name: load docker image
|
- name: load docker image
|
||||||
env:
|
|
||||||
imgname: ${{ needs.build.outputs.imgname}}
|
|
||||||
version: ${{ needs.build.outputs.version }}
|
|
||||||
run: |
|
run: |
|
||||||
unzip -q /tmp/${imgname}-docker-${version}.zip -d /tmp
|
docker load < /tmp/image.tar.gz
|
||||||
docker load < /tmp/${imgname}-docker-${version}
|
|
||||||
- name: docker compose up
|
- name: docker compose up
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
env:
|
env:
|
||||||
|
@ -152,15 +155,11 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: emqx-docker-image-zip
|
name: image
|
||||||
path: /tmp
|
path: /tmp
|
||||||
- name: load docker image
|
- name: load docker image
|
||||||
env:
|
|
||||||
imgname: ${{ needs.build.outputs.imgname }}
|
|
||||||
version: ${{ needs.build.outputs.version }}
|
|
||||||
run: |
|
run: |
|
||||||
unzip -q /tmp/${imgname}-docker-${version}.zip -d /tmp
|
docker load < /tmp/image.tar.gz
|
||||||
docker load < /tmp/${imgname}-docker-${version}
|
|
||||||
- name: docker compose up
|
- name: docker compose up
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
env:
|
env:
|
||||||
|
@ -259,15 +258,11 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: emqx-docker-image-zip
|
name: image
|
||||||
path: /tmp
|
path: /tmp
|
||||||
- name: load docker image
|
- name: load docker image
|
||||||
env:
|
|
||||||
imgname: ${{ needs.build.outputs.imgname }}
|
|
||||||
version: ${{ needs.build.outputs.version }}
|
|
||||||
run: |
|
run: |
|
||||||
unzip -q /tmp/${imgname}-docker-${version}.zip -d /tmp
|
docker load < /tmp/image.tar.gz
|
||||||
docker load < /tmp/${imgname}-docker-${version}
|
|
||||||
- name: docker compose up
|
- name: docker compose up
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
env:
|
env:
|
||||||
|
@ -355,15 +350,11 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: emqx-docker-image-zip
|
name: image
|
||||||
path: /tmp
|
path: /tmp
|
||||||
- name: load docker image
|
- name: load docker image
|
||||||
env:
|
|
||||||
imgname: ${{ needs.build.outputs.imgname }}
|
|
||||||
version: ${{ needs.build.outputs.version }}
|
|
||||||
run: |
|
run: |
|
||||||
unzip -q /tmp/${imgname}-docker-${version}.zip -d /tmp
|
docker load < /tmp/image.tar.gz
|
||||||
docker load < /tmp/${imgname}-docker-${version}
|
|
||||||
- name: docker compose up
|
- name: docker compose up
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -25,13 +25,15 @@ jobs:
|
||||||
echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token
|
echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token
|
||||||
make deps-emqx-ee
|
make deps-emqx-ee
|
||||||
echo "TARGET=emqx/emqx-ee" >> $GITHUB_ENV
|
echo "TARGET=emqx/emqx-ee" >> $GITHUB_ENV
|
||||||
|
echo "PROFILE=emqx-ee" >> $GITHUB_ENV
|
||||||
echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
|
echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo "TARGET=emqx/emqx" >> $GITHUB_ENV
|
echo "TARGET=emqx/emqx" >> $GITHUB_ENV
|
||||||
|
echo "PROFILE=emqx" >> $GITHUB_ENV
|
||||||
echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
|
echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
- name: make emqx image
|
- name: make emqx image
|
||||||
run: make docker
|
run: make ${PROFILE}-docker
|
||||||
- name: run emqx
|
- name: run emqx
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
run: |
|
run: |
|
||||||
|
@ -79,11 +81,15 @@ jobs:
|
||||||
echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token
|
echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token
|
||||||
make deps-emqx-ee
|
make deps-emqx-ee
|
||||||
echo "TARGET=emqx/emqx-ee" >> $GITHUB_ENV
|
echo "TARGET=emqx/emqx-ee" >> $GITHUB_ENV
|
||||||
|
echo "PROFILE=emqx-ee" >> $GITHUB_ENV
|
||||||
|
echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo "TARGET=emqx/emqx" >> $GITHUB_ENV
|
echo "TARGET=emqx/emqx" >> $GITHUB_ENV
|
||||||
|
echo "PROFILE=emqx" >> $GITHUB_ENV
|
||||||
|
echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
- name: make emqx image
|
- name: make emqx image
|
||||||
run: make docker
|
run: make ${PROFILE}-docker
|
||||||
- name: install k3s
|
- name: install k3s
|
||||||
env:
|
env:
|
||||||
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||||
|
@ -105,11 +111,10 @@ jobs:
|
||||||
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
run: |
|
run: |
|
||||||
version=$(./pkg-vsn.sh)
|
sudo docker save ${TARGET}:${EMQX_TAG} -o emqx.tar.gz
|
||||||
sudo docker save ${TARGET}:$version -o emqx.tar.gz
|
|
||||||
sudo k3s ctr image import emqx.tar.gz
|
sudo k3s ctr image import emqx.tar.gz
|
||||||
|
|
||||||
sed -i -r "s/^appVersion: .*$/appVersion: \"${version}\"/g" deploy/charts/emqx/Chart.yaml
|
sed -i -r "s/^appVersion: .*$/appVersion: \"${EMQX_TAG}\"/g" deploy/charts/emqx/Chart.yaml
|
||||||
sed -i '/emqx_telemetry/d' deploy/charts/emqx/values.yaml
|
sed -i '/emqx_telemetry/d' deploy/charts/emqx/values.yaml
|
||||||
|
|
||||||
helm install emqx \
|
helm install emqx \
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -145,11 +145,18 @@ $1: $1-rel
|
||||||
endef
|
endef
|
||||||
$(foreach pt,$(PKG_PROFILES),$(eval $(call gen-pkg-target,$(pt))))
|
$(foreach pt,$(PKG_PROFILES),$(eval $(call gen-pkg-target,$(pt))))
|
||||||
|
|
||||||
|
## docker target is to create docker instructions
|
||||||
|
.PHONY: $(REL_PROFILES:%=%-docker)
|
||||||
|
define gen-docker-target
|
||||||
|
$1-docker: $(COMMON_DEPS)
|
||||||
|
@$(BUILD) $1 docker
|
||||||
|
endef
|
||||||
|
ALL_ZIPS = $(REL_PROFILES)
|
||||||
|
$(foreach zt,$(ALL_ZIPS),$(eval $(call gen-docker-target,$(zt))))
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: $(PROFILE) quickrun
|
run: $(PROFILE) quickrun
|
||||||
|
|
||||||
.PHONY: quickrun
|
.PHONY: quickrun
|
||||||
quickrun:
|
quickrun:
|
||||||
./_build/$(PROFILE)/rel/emqx/bin/emqx console
|
./_build/$(PROFILE)/rel/emqx/bin/emqx console
|
||||||
|
|
||||||
include docker.mk
|
|
||||||
|
|
17
build
17
build
|
@ -127,6 +127,20 @@ make_zip() {
|
||||||
(cd "${tard}" && zip -qr - emqx) > "${zipball}"
|
(cd "${tard}" && zip -qr - emqx) > "${zipball}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
make_docker() {
|
||||||
|
## Build Docker image
|
||||||
|
echo "DOCKER BUILD: Build Docker image."
|
||||||
|
echo "DOCKER BUILD: build version -> $PKG_VSN."
|
||||||
|
echo "DOCKER BUILD: docker repo -> emqx/$PROFILE "
|
||||||
|
|
||||||
|
docker build --no-cache \
|
||||||
|
--build-arg BUILD_FROM="ghcr.io/emqx/emqx-builder/4.4:${OTP:-23.3.4.8-1}-alpine3.14" \
|
||||||
|
--build-arg RUN_FROM="alpine:3.14" \
|
||||||
|
--build-arg EMQX_NAME="$PROFILE" \
|
||||||
|
--tag "emqx/$PROFILE:$PKG_VSN" \
|
||||||
|
-f deploy/docker/Dockerfile .
|
||||||
|
}
|
||||||
|
|
||||||
log "building artifact=$ARTIFACT for profile=$PROFILE"
|
log "building artifact=$ARTIFACT for profile=$PROFILE"
|
||||||
|
|
||||||
case "$ARTIFACT" in
|
case "$ARTIFACT" in
|
||||||
|
@ -147,6 +161,9 @@ case "$ARTIFACT" in
|
||||||
make -C "deploy/packages/${PKGERDIR}" clean
|
make -C "deploy/packages/${PKGERDIR}" clean
|
||||||
EMQX_REL="$(pwd)" EMQX_BUILD="${PROFILE}" SYSTEM="${SYSTEM}" make -C "deploy/packages/${PKGERDIR}"
|
EMQX_REL="$(pwd)" EMQX_BUILD="${PROFILE}" SYSTEM="${SYSTEM}" make -C "deploy/packages/${PKGERDIR}"
|
||||||
;;
|
;;
|
||||||
|
docker)
|
||||||
|
make_docker
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
log "Unknown artifact $ARTIFACT"
|
log "Unknown artifact $ARTIFACT"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
ARG BUILD_FROM=emqx/build-env:erl23.2.7.2-emqx-2-alpine-amd64
|
ARG BUILD_FROM=ghcr.io/emqx/emqx-builder/4.4:23.3.4.8-1-alpine3.14
|
||||||
ARG RUN_FROM=alpine:3.12
|
ARG RUN_FROM=alpine:3.14
|
||||||
FROM ${BUILD_FROM} AS builder
|
FROM ${BUILD_FROM} AS builder
|
||||||
|
|
||||||
ARG QEMU_ARCH=x86_64
|
|
||||||
COPY tmp/qemu-$QEMU_ARCH-stati* /usr/bin/
|
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
git \
|
git \
|
||||||
curl \
|
curl \
|
||||||
|
@ -32,21 +29,9 @@ RUN cd /emqx \
|
||||||
|
|
||||||
FROM $RUN_FROM
|
FROM $RUN_FROM
|
||||||
|
|
||||||
# Basic build-time metadata as defined at http://label-schema.org
|
|
||||||
LABEL org.label-schema.docker.dockerfile="Dockerfile" \
|
|
||||||
org.label-schema.license="GNU" \
|
|
||||||
org.label-schema.name="emqx" \
|
|
||||||
org.label-schema.version=${PKG_VSN} \
|
|
||||||
org.label-schema.description="EMQ (Erlang MQTT Broker) is a distributed, massively scalable, highly extensible MQTT messaging broker written in Erlang/OTP." \
|
|
||||||
org.label-schema.url="https://emqx.io" \
|
|
||||||
org.label-schema.vcs-type="Git" \
|
|
||||||
org.label-schema.vcs-url="https://github.com/emqx/emqx" \
|
|
||||||
maintainer="EMQ X Team <support@emqx.io>"
|
|
||||||
|
|
||||||
ARG QEMU_ARCH=x86_64
|
|
||||||
ARG EMQX_NAME=emqx
|
ARG EMQX_NAME=emqx
|
||||||
|
|
||||||
COPY deploy/docker/docker-entrypoint.sh tmp/qemu-$QEMU_ARCH-stati* /usr/bin/
|
COPY deploy/docker/docker-entrypoint.sh /usr/bin/
|
||||||
COPY --from=builder /emqx/_build/$EMQX_NAME/rel/emqx /opt/emqx
|
COPY --from=builder /emqx/_build/$EMQX_NAME/rel/emqx /opt/emqx
|
||||||
|
|
||||||
RUN ln -s /opt/emqx/bin/* /usr/local/bin/
|
RUN ln -s /opt/emqx/bin/* /usr/local/bin/
|
||||||
|
|
188
docker.mk
188
docker.mk
|
@ -1,188 +0,0 @@
|
||||||
#!/usr/bin/make -f
|
|
||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
## default globals.
|
|
||||||
## when built with `make docker` command the default profile is either emqx or emqx-ee (for enterprise)
|
|
||||||
## or the TARGET varialbe can be set beforehand to force a different name
|
|
||||||
TARGET ?= emqx/$(PROFILE)
|
|
||||||
QEMU_ARCH ?= x86_64
|
|
||||||
ARCH ?= amd64
|
|
||||||
QEMU_VERSION ?= v5.0.0-2
|
|
||||||
OS ?= alpine
|
|
||||||
export PKG_VSN ?= $(shell $(CURDIR)/pkg-vsn.sh)
|
|
||||||
|
|
||||||
ifeq ($(findstring emqx-ee, $(TARGET)), emqx-ee)
|
|
||||||
ARCH_LIST := amd64 arm64v8 arm32v7
|
|
||||||
EMQX_NAME := emqx-ee
|
|
||||||
else ifeq ($(findstring emqx-edge, $(TARGET)), emqx-edge)
|
|
||||||
ARCH_LIST := amd64 arm64v8 arm32v7 i386 s390x
|
|
||||||
EMQX_NAME := emqx-edge
|
|
||||||
else
|
|
||||||
ARCH_LIST := amd64 arm64v8 arm32v7 i386 s390x
|
|
||||||
EMQX_NAME := emqx
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: docker
|
|
||||||
docker: docker-build docker-tag docker-save
|
|
||||||
|
|
||||||
.PHONY: docker-prepare
|
|
||||||
docker-prepare:
|
|
||||||
## Prepare the machine before any code installation scripts
|
|
||||||
# @echo "PREPARE: Setting up dependencies."
|
|
||||||
# @apt update -y
|
|
||||||
# @apt install --only-upgrade docker-ce -y
|
|
||||||
|
|
||||||
## Update docker configuration to enable docker manifest command
|
|
||||||
@echo "PREPARE: Updating docker configuration"
|
|
||||||
@mkdir -p $$HOME/.docker
|
|
||||||
|
|
||||||
# enable experimental to use docker manifest command
|
|
||||||
@echo '{ "experimental": "enabled" }' | tee $$HOME/.docker/config.json
|
|
||||||
# enable experimental
|
|
||||||
@echo '{ "experimental": true, "storage-driver": "overlay2", "max-concurrent-downloads": 50, "max-concurrent-uploads": 50 }' | tee /etc/docker/daemon.json
|
|
||||||
@service docker restart
|
|
||||||
|
|
||||||
.PHONY: docker-build
|
|
||||||
docker-build:
|
|
||||||
## Build Docker image
|
|
||||||
@echo "DOCKER BUILD: Build Docker image."
|
|
||||||
@echo "DOCKER BUILD: build version -> $(PKG_VSN)."
|
|
||||||
@echo "DOCKER BUILD: arch - $(ARCH)."
|
|
||||||
@echo "DOCKER BUILD: qemu arch - $(QEMU_ARCH)."
|
|
||||||
@echo "DOCKER BUILD: docker repo - $(TARGET) "
|
|
||||||
@echo "DOCKER BUILD: emqx name - $(EMQX_NAME)."
|
|
||||||
|
|
||||||
## Prepare qemu to build images other then x86_64 on travis
|
|
||||||
@echo "PREPARE: Qemu" \
|
|
||||||
&& docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
|
||||||
|
|
||||||
@mkdir -p tmp \
|
|
||||||
&& cd tmp \
|
|
||||||
&& curl -L -o qemu-$(QEMU_ARCH)-static.tar.gz https://github.com/multiarch/qemu-user-static/releases/download/$(QEMU_VERSION)/qemu-$(QEMU_ARCH)-static.tar.gz \
|
|
||||||
&& tar xzf qemu-$(QEMU_ARCH)-static.tar.gz \
|
|
||||||
&& cd -
|
|
||||||
|
|
||||||
@docker build --no-cache \
|
|
||||||
--build-arg PKG_VSN=$(PKG_VSN) \
|
|
||||||
--build-arg BUILD_FROM=emqx/build-env:erl23.2.7.2-emqx-2-alpine-$(ARCH) \
|
|
||||||
--build-arg RUN_FROM=$(ARCH)/alpine:3.12 \
|
|
||||||
--build-arg EMQX_NAME=$(EMQX_NAME) \
|
|
||||||
--build-arg QEMU_ARCH=$(QEMU_ARCH) \
|
|
||||||
--tag $(TARGET):build-$(OS)-$(ARCH) \
|
|
||||||
-f deploy/docker/Dockerfile .
|
|
||||||
|
|
||||||
.PHONY: docker-tag
|
|
||||||
docker-tag:
|
|
||||||
@echo "DOCKER TAG: Tag Docker image."
|
|
||||||
@for arch in $(ARCH_LIST); do \
|
|
||||||
if [ -n "$$(docker images -q $(TARGET):build-$(OS)-$${arch})" ]; then \
|
|
||||||
docker tag $(TARGET):build-$(OS)-$${arch} $(TARGET):$(PKG_VSN)-$(OS)-$${arch}; \
|
|
||||||
echo "DOCKER TAG: $(TARGET):$(PKG_VSN)-$(OS)-$${arch}"; \
|
|
||||||
if [ $${arch} = amd64 ]; then \
|
|
||||||
docker tag $(TARGET):$(PKG_VSN)-$(OS)-amd64 $(TARGET):$(PKG_VSN); \
|
|
||||||
echo "DOCKER TAG: $(TARGET):$(PKG_VSN)"; \
|
|
||||||
fi; \
|
|
||||||
fi; \
|
|
||||||
done
|
|
||||||
|
|
||||||
.PHONY: docker-save
|
|
||||||
docker-save:
|
|
||||||
@echo "DOCKER SAVE: Save Docker image."
|
|
||||||
|
|
||||||
@mkdir -p _packages/$(EMQX_NAME)
|
|
||||||
|
|
||||||
@if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN))" ]; then \
|
|
||||||
docker save $(TARGET):$(PKG_VSN) > $(EMQX_NAME)-docker-$(PKG_VSN); \
|
|
||||||
zip -r -m $(EMQX_NAME)-docker-$(PKG_VSN).zip $(EMQX_NAME)-docker-$(PKG_VSN); \
|
|
||||||
mv ./$(EMQX_NAME)-docker-$(PKG_VSN).zip _packages/$(EMQX_NAME)/$(EMQX_NAME)-docker-$(PKG_VSN).zip; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
@for arch in $(ARCH_LIST); do \
|
|
||||||
if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN)-$(OS)-$${arch})" ]; then \
|
|
||||||
docker save $(TARGET):$(PKG_VSN)-$(OS)-$${arch} > $(EMQX_NAME)-docker-$(PKG_VSN)-$(OS)-$${arch}; \
|
|
||||||
zip -r -m $(EMQX_NAME)-docker-$(PKG_VSN)-$(OS)-$${arch}.zip $(EMQX_NAME)-docker-$(PKG_VSN)-$(OS)-$${arch}; \
|
|
||||||
mv ./$(EMQX_NAME)-docker-$(PKG_VSN)-$(OS)-$${arch}.zip _packages/$(EMQX_NAME)/$(EMQX_NAME)-docker-$(PKG_VSN)-$(OS)-$${arch}.zip; \
|
|
||||||
fi; \
|
|
||||||
done
|
|
||||||
|
|
||||||
.PHONY: docker-push
|
|
||||||
docker-push:
|
|
||||||
@echo "DOCKER PUSH: Push Docker image.";
|
|
||||||
@echo "DOCKER PUSH: pushing - $(TARGET):$(PKG_VSN).";
|
|
||||||
|
|
||||||
@if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN))" ]; then \
|
|
||||||
docker push $(TARGET):$(PKG_VSN); \
|
|
||||||
docker tag $(TARGET):$(PKG_VSN) $(TARGET):latest; \
|
|
||||||
docker push $(TARGET):latest; \
|
|
||||||
fi;
|
|
||||||
|
|
||||||
@for arch in $(ARCH_LIST); do \
|
|
||||||
if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN)-$(OS)-$${arch})" ]; then \
|
|
||||||
docker push $(TARGET):$(PKG_VSN)-$(OS)-$${arch}; \
|
|
||||||
fi; \
|
|
||||||
done
|
|
||||||
|
|
||||||
.PHONY: docker-manifest-list
|
|
||||||
docker-manifest-list:
|
|
||||||
version="docker manifest create --amend $(TARGET):$(PKG_VSN)"; \
|
|
||||||
latest="docker manifest create --amend $(TARGET):latest"; \
|
|
||||||
for arch in $(ARCH_LIST); do \
|
|
||||||
if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN)-$(OS)-$${arch})" ];then \
|
|
||||||
version="$${version} $(TARGET):$(PKG_VSN)-$(OS)-$${arch} "; \
|
|
||||||
latest="$${latest} $(TARGET):$(PKG_VSN)-$(OS)-$${arch} "; \
|
|
||||||
fi; \
|
|
||||||
done; \
|
|
||||||
eval $$version; \
|
|
||||||
eval $$latest;
|
|
||||||
|
|
||||||
for arch in $(ARCH_LIST); do \
|
|
||||||
case $${arch} in \
|
|
||||||
"amd64") \
|
|
||||||
if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN)-$(OS)-$${arch})" ]; then \
|
|
||||||
docker manifest annotate $(TARGET):$(PKG_VSN) $(TARGET):$(PKG_VSN)-$(OS)-amd64 --os=linux --arch=amd64; \
|
|
||||||
docker manifest annotate $(TARGET):latest $(TARGET):$(PKG_VSN)-$(OS)-amd64 --os=linux --arch=amd64; \
|
|
||||||
fi; \
|
|
||||||
;; \
|
|
||||||
"arm64v8") \
|
|
||||||
if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN)-$(OS)-$${arch})" ]; then \
|
|
||||||
docker manifest annotate $(TARGET):$(PKG_VSN) $(TARGET):$(PKG_VSN)-$(OS)-arm64v8 --os=linux --arch=arm64 --variant=v8; \
|
|
||||||
docker manifest annotate $(TARGET):latest $(TARGET):$(PKG_VSN)-$(OS)-arm64v8 --os=linux --arch=arm64 --variant=v8; \
|
|
||||||
fi; \
|
|
||||||
;; \
|
|
||||||
"arm32v7") \
|
|
||||||
if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN)-$(OS)-$${arch})" ]; then \
|
|
||||||
docker manifest annotate $(TARGET):$(PKG_VSN) $(TARGET):$(PKG_VSN)-$(OS)-arm32v7 --os=linux --arch=arm --variant=v7; \
|
|
||||||
docker manifest annotate $(TARGET):latest $(TARGET):$(PKG_VSN)-$(OS)-arm32v7 --os=linux --arch=arm --variant=v7; \
|
|
||||||
fi; \
|
|
||||||
;; \
|
|
||||||
"i386") \
|
|
||||||
if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN)-$(OS)-$${arch})" ]; then \
|
|
||||||
docker manifest annotate $(TARGET):$(PKG_VSN) $(TARGET):$(PKG_VSN)-$(OS)-i386 --os=linux --arch=386; \
|
|
||||||
docker manifest annotate $(TARGET):latest $(TARGET):$(PKG_VSN)-$(OS)-i386 --os=linux --arch=386; \
|
|
||||||
fi; \
|
|
||||||
;; \
|
|
||||||
"s390x") \
|
|
||||||
if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN)-$(OS)-$${arch})" ]; then \
|
|
||||||
docker manifest annotate $(TARGET):$(PKG_VSN) $(TARGET):$(PKG_VSN)-$(OS)-s390x --os=linux --arch=s390x; \
|
|
||||||
docker manifest annotate $(TARGET):latest $(TARGET):$(PKG_VSN)-$(OS)-s390x --os=linux --arch=s390x; \
|
|
||||||
fi; \
|
|
||||||
;; \
|
|
||||||
esac; \
|
|
||||||
done;
|
|
||||||
|
|
||||||
docker manifest inspect $(TARGET):$(PKG_VSN)
|
|
||||||
docker manifest push $(TARGET):$(PKG_VSN);
|
|
||||||
docker manifest inspect $(TARGET):latest
|
|
||||||
docker manifest push $(TARGET):latest;
|
|
||||||
|
|
||||||
.PHONY: docker-clean
|
|
||||||
docker-clean:
|
|
||||||
@echo "DOCKER CLEAN: Clean Docker image."
|
|
||||||
|
|
||||||
@if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN))" ]; then docker rmi -f $$(docker images -q $(TARGET):$(PKG_VSN)); fi
|
|
||||||
|
|
||||||
@for arch in $(ARCH_LIST); do \
|
|
||||||
if [ -n "$$(docker images -q $(TARGET):$(PKG_VSN)-$(OS)-$${arch})" ]; then \
|
|
||||||
docker rmi -f $$(docker images -q $(TARGET):$(PKG_VSN)-$(OS)-$${arch}); \
|
|
||||||
fi \
|
|
||||||
done
|
|
Loading…
Reference in New Issue