Docker编译 ¶
hummingbird-core服务编译 ¶
Dockerfile 文件如下,文件所在目录hummingbird/cmd/hummingbird-core
dockerfile
ARG BUILDER_BASE=registry.cn-shanghai.aliyuncs.com/winc-edgex/edgex:1.18.8-alpine3.16
FROM ${BUILDER_BASE} AS builder
WORKDIR /edge
COPY . .
RUN make cmd/hummingbird-core/hummingbird-core
#Next image - Copy built Go binary into new workspace
FROM alpine:3.16
ENV APP_PORT=58081
ENV WEB_PORT=3000
EXPOSE $APP_PORT
EXPOSE $WEB_PORT
WORKDIR /var/bin/
COPY --from=builder /edge/cmd/hummingbird-core/hummingbird-core /bin/
COPY --from=builder /edge/cmd/hummingbird-core/res/configuration.toml.dist /etc/hummingbird-core/configuration.toml
COPY --from=builder /edge/cmd/hummingbird-ui/build /var/bin/cmd/hummingbird-ui/build
CMD ["/bin/sh", "-c", "/bin/hummingbird-core --confdir=/etc/hummingbird-core/configuration.toml"]
运行如下命令可以构建hummingbird-core服务镜像
docker buildx build --platform linux/amd64 -t 您的仓库地址 -f cmd/hummingbird-core/Dockerfile --push .
mqtt-broker服务编译 ¶
Dockerfile 文件如下,文件所在目录hummingbird/cmd/mqtt-broker
dockerfile
ARG BUILDER_BASE=golang:latest
FROM ${BUILDER_BASE} AS builder
WORKDIR /edge
# gitlab
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build make cmd/mqtt-broker/mqtt-broker
#Next image - Copy built Go binary into new workspace
FROM alpine:3.16
RUN --mount=type=cache,target=/var/cache/apk apk add --update --no-cache dumb-init
EXPOSE 58090
WORKDIR /
COPY --from=builder /edge/cmd/mqtt-broker/mqtt-broker /bin/
COPY --from=builder /edge/cmd/mqtt-broker/res/configuration.yml.dist /etc/emqtt-broker/res/configuration.yml
#RUN mkdir -p /logs/mqtt-broker
CMD ["/bin/sh", "-c", "/bin/mqtt-broker start -c=/etc/emqtt-broker/res/configuration.yml"]
运行如下命令可以构建hummingbird-core服务镜像
docker buildx build --platform linux/amd64 -t 您的仓库地址 -f cmd/mqtt-broker/Dockerfile --push .