From 5f57dca29e68bc8499b89a7c52c313da8f60e8ff Mon Sep 17 00:00:00 2001 From: Bryan Pedini Date: Tue, 21 Apr 2020 12:17:44 +0200 Subject: [PATCH 1/2] implemented Docker, added default configuration --- Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ config.example.yml | 12 ++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Dockerfile create mode 100644 config.example.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cb37723 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM golang:1.14-buster AS build-env + +COPY . ${GOPATH}/src/github.com/rls-moe/nyx +WORKDIR ${GOPATH}/src/github.com/rls-moe/nyx + +RUN go build -o $GOPATH/bin/nyx + +FROM debian:bullseye +LABEL maintainer="b.pedini@bjphoster.com" + +EXPOSE 8080 + +RUN groupadd \ + --gid 1000 \ + nyx && \ + useradd \ + --home-dir /opt/nyx \ + --comment "Nyx Board" \ + --gid nyx \ + --create-home \ + --no-user-group \ + --uid 1000 \ + --shell /bin/bash \ + nyx + +ENV USER nyx + +CMD [ "/usr/local/bin/nyx" ] + +COPY --from=build-env /go/bin/nyx /opt/nyx/nyx +COPY --from=build-env /go/src/github.com/rls-moe/nyx/config.example.yml /opt/nyx/config.yml +RUN ln -s \ + /opt/nyx/nyx \ + /usr/local/bin/nyx && \ + chown -R \ + nyx:nyx /opt/nyx diff --git a/config.example.yml b/config.example.yml new file mode 100644 index 0000000..39f6a7d --- /dev/null +++ b/config.example.yml @@ -0,0 +1,12 @@ +site: + title: "NyxChan" + description: "NyxChan Default Configuration" + +db: + file: ":memory:" + +mastersecret: "changeme" +listen_on: ":8080" + +captcha: + mode: "internal" From 1b051814fc50e03eba8d3bd7636de4615cbeec16 Mon Sep 17 00:00:00 2001 From: Bryan Pedini Date: Tue, 21 Apr 2020 19:46:34 +0200 Subject: [PATCH 2/2] fixed board server not being on right user and working directory it didn't load the config file because of that --- Dockerfile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index cb37723..58ac580 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,14 +23,11 @@ RUN groupadd \ --shell /bin/bash \ nyx -ENV USER nyx - -CMD [ "/usr/local/bin/nyx" ] - COPY --from=build-env /go/bin/nyx /opt/nyx/nyx COPY --from=build-env /go/src/github.com/rls-moe/nyx/config.example.yml /opt/nyx/config.yml -RUN ln -s \ - /opt/nyx/nyx \ - /usr/local/bin/nyx && \ - chown -R \ +RUN chown -R \ nyx:nyx /opt/nyx + +WORKDIR /opt/nyx +USER nyx +CMD [ "/opt/nyx/nyx" ]