From 262bee90229b391cf398a2c5ad6d08c5e9611eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Thu, 7 Jan 2021 10:04:36 +0100 Subject: [PATCH] fix: do not attempt to bind on ipv6 in docker (resolve #84) --- .dockerignore | 7 ++++++- Dockerfile | 19 ++++++------------- README.md | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.dockerignore b/.dockerignore index 2eea525..9cf1967 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,6 @@ -.env \ No newline at end of file +.env +config*.yml +!config.default.yml +*.db +*.exe +wakapi \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9619b1a..72ea1f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Build Stage -FROM golang:1.13 AS build-env +FROM golang:1.15 AS build-env WORKDIR /src ADD ./go.mod . RUN go mod download @@ -8,19 +8,11 @@ RUN go mod download ADD . . RUN go build -o wakapi -# Final Stage +# Run Stage # When running the application using `docker run`, you can pass environment variables # to override config values using `-e` syntax. -# Available options are: -# – WAKAPI_DB_TYPE -# – WAKAPI_DB_USER -# – WAKAPI_DB_PASSWORD -# – WAKAPI_DB_HOST -# – WAKAPI_DB_PORT -# – WAKAPI_DB_NAME -# – WAKAPI_PASSWORD_SALT -# – WAKAPI_BASE_PATH +# Available options can be found in [README.md#-configuration](README.md#-configuration) FROM debian WORKDIR /app @@ -32,13 +24,14 @@ ENV WAKAPI_DB_PASSWORD '' ENV WAKAPI_DB_HOST '' ENV WAKAPI_DB_NAME=/data/wakapi.db ENV WAKAPI_PASSWORD_SALT '' +ENV WAKAPI_LISTEN_IPV4 '0.0.0.0' +ENV WAKAPI_INSECURE_COOKIES 'true' COPY --from=build-env /src/wakapi /app/ COPY --from=build-env /src/config.default.yml /app/config.yml COPY --from=build-env /src/version.txt /app/ -RUN sed -i 's/listen_ipv4: 127.0.0.1/listen_ipv4: 0.0.0.0/g' /app/config.yml -RUN sed -i 's/insecure_cookies: false/insecure_cookies: true/g' /app/config.yml +RUN sed -i 's/listen_ipv6: ::1/listen_ipv6: /g' /app/config.yml ADD static /app/static ADD data /app/data diff --git a/README.md b/README.md index 5cc79d5..384de23 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ To use the hosted version set `api_url = https://wakapi.dev/api/heartbeat`. Howe ### Run with Docker ```bash -docker run -d -p 3000:3000 --name wakapi n1try/wakapi +docker run -d -p 3000:3000 -e "WAKAPI_PASSWORD_SALT=$(openssl rand -hex 16)" --name wakapi n1try/wakapi ``` By default, SQLite is used as a database. To run Wakapi in Docker with MySQL or Postgres, see [Dockerfile](https://github.com/muety/wakapi/blob/master/Dockerfile) and [config.default.yml](https://github.com/muety/wakapi/blob/master/config.default.yml) for further options. @@ -73,7 +73,7 @@ You can specify configuration options either via a config file (default: `config | `app.custom_languages` | - | - | Map from file endings to language names | | `server.port` | `WAKAPI_PORT` | `3000` | Port to listen on | | `server.listen_ipv4` | `WAKAPI_LISTEN_IPV4` | `127.0.0.1` | IPv4 network address to listen on (leave blank to disable IPv4) | -| `server.listen_ipv6` | `WAKAPI_LISTEN_IPV6` | `` | IPv6 network address to listen on (leave blank to disable IPv6) | +| `server.listen_ipv6` | `WAKAPI_LISTEN_IPV6` | `::1` | IPv6 network address to listen on (leave blank to disable IPv6) | | `server.tls_cert_path` | `WAKAPI_TLS_CERT_PATH` | - | Path of SSL server certificate (leave blank to not use HTTPS) | | `server.tls_key_path` | `WAKAPI_TLS_KEY_PATH` | - | Path of SSL server private key (leave blank to not use HTTPS) | | `server.base_path` | `WAKAPI_BASE_PATH` | `/` | Web base path (change when running behind a proxy under a sub-path) |