Skip to content

Commit

Permalink
fix: do not attempt to bind on ipv6 in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Jan 7, 2021
1 parent 9766d8e commit 9e735eb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
7 changes: 6 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
.env
.env
config*.yml
!config.default.yml
*.db
*.exe
wakapi
19 changes: 6 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
# 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

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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) |
Expand Down

0 comments on commit 9e735eb

Please sign in to comment.