0

I work with nsq_to_file utility while running some automation code, I wanted to automate that utility as a docker-compose service. I can't find any documentation about using this utility with docker. I use it as follows:

./nsq_to_file --lookupd-http-address=<http_address> --topic=ta-gcp-test -output-dir=/path/to/local/dir -filename-format=local_file_name

Does anyone have any input on that?

1 Answers1

0

You can build a Docker container with the nsq_to_file executable, it would look like this:

#
# 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" ]

You can then build it and run it:

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 ...

Oliver
  • 11,857
  • 2
  • 36
  • 42