nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
15.89k stars 1.4k forks source link

Building NATS docker image #2736

Closed nhatmicls closed 2 years ago

nhatmicls commented 2 years ago

Hi, im try building nats image with some config i want to build with. But it have some problem with it. How can I fix this ? Thanks.

Folder tree

.
nats-security
+-- something
+-- nats-server (I git clone this repo https://github.com/nats-io/nats-server)
|    +-- docker
|    |    +-- Dockerfile.nightly
+-- something

Building command docker build -f "nats-server/docker/Dockerfile.nightly" -t nats_scada .

Result build:

Successfully built b652acb3e212
Successfully tagged nats_scada:latest

Here is docker file (it nearly same Dockerfile.nightly)

FROM golang:1.16-alpine AS builder

ARG VERSION="nightly"

RUN apk add --update git
RUN mkdir -p src/github.com/nats-io && \
    cd src/github.com/nats-io/ && \
    git clone https://github.com/nats-io/natscli.git && \
    cd natscli/nats && \
    go build -ldflags "-w -X main.version=${VERSION}" -o /nats

RUN go get github.com/nats-io/nsc

FROM alpine:latest

RUN apk add --update ca-certificates && mkdir -p /nats/bin && mkdir /nats/conf

COPY natsio/server.conf /nats/conf/server.conf
COPY natsio/account.conf /nats/conf/account.conf
COPY nats-server /bin/nats-server
COPY --from=builder /nats /bin/nats
COPY --from=builder /go/bin/nsc /bin/nsc

EXPOSE 4222 8222 6222 5222

ENTRYPOINT ["/bin/nats-server"]
CMD ["-c", "/nats/conf/server.conf"]

But when I try running this image it give me error

Run command: docker run --rm -it nats_scada

docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/nats-server": permission denied: unknown.

ripienaar commented 2 years ago

Nightly builds the nats server outside of docker and then copies it in.

In your setup it appears that you do not and that what is copied in is a directory not a file.

The nightly container is made to use with goreleaser not general use

nhatmicls commented 2 years ago

Thanks

ripienaar commented 2 years ago

If you just want to modify config files then use ours as your base image with FROM and then. In yours just copy in new check fig files.