我在运行一些自动化代码时使用nsq_to_file 实用程序,我想将该实用程序自动化为 docker-compose 服务。我找不到任何有关将此实用程序与 docker 一起使用的文档。我使用它如下:
./nsq_to_file --lookupd-http-address=<http_address> --topic=ta-gcp-test -output-dir=/path/to/local/dir -filename-format=local_file_name
有人对此有任何意见吗?
我在运行一些自动化代码时使用nsq_to_file 实用程序,我想将该实用程序自动化为 docker-compose 服务。我找不到任何有关将此实用程序与 docker 一起使用的文档。我使用它如下:
./nsq_to_file --lookupd-http-address=<http_address> --topic=ta-gcp-test -output-dir=/path/to/local/dir -filename-format=local_file_name
有人对此有任何意见吗?
您可以使用 nsq_to_file 可执行文件构建 Docker 容器,它看起来像这样:
#
# build container
#
FROM golang:1.17-alpine as builder
RUN apk update && apk add git
RUN git clone https://github.com/nsqio/nsq
RUN cd nsq/apps/nsq_to_file/ && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /nsq_to_file .
#
# scratch release container
#
FROM scratch as scratch
COPY --from=builder /nsq_to_file /nsq_to_file
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
# Run as non-root user for secure environments
USER 59000:59000
ENTRYPOINT [ "/nsq_to_file" ]
然后,您可以构建并运行它:
docker build -t oliver006/nsq_to_file -f Dockerfile .
docker run --rm oliver006/nsq_to_file --lookupd-http-address=<http_address> --topic=ta-gcp-test ...