diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 298d218..179f118 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,35 @@ # Build Stage -FROM golang:alpine AS build-env +FROM golang:1.13 AS build-env ADD . /src RUN cd /src && go build -o wakapi # Final Stage + # When running the application using `docker run`, you can pass environment variables # to override config values from .env using `-e` syntax. # Available options are: +# – WAKAPI_DB_TYPE # – WAKAPI_DB_USER # – WAKAPI_DB_PASSWORD # – WAKAPI_DB_HOST +# – WAKAPI_DB_PORT # – WAKAPI_DB_NAME -FROM alpine +# – WAKAPI_DEFAULT_USER_NAME +# – WAKAPI_DEFAULT_USER_PASSWORD + +FROM debian WORKDIR /app + COPY --from=build-env /src/wakapi /app/ COPY --from=build-env /src/config.ini /app/ COPY --from=build-env /src/.env.example /app/.env + RUN sed -i 's/listen = 127.0.0.1/listen = 0.0.0.0/g' /app/config.ini + ADD static /app/static +ADD data /app/data +ADD migrations /app/migrations +ADD views /app/views ADD wait-for-it.sh . + ENTRYPOINT ./wait-for-it.sh \ No newline at end of file diff --git a/README.md b/README.md index de510b8..0c68a67 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ ### Run with Docker * Edit `docker-compose.yml` file and change passwords for the DB -* Build the container `docker-compose build` * Start the application `docker-compose up -d` * To get the api key look in the logs `docker-compose logs | grep "API key"` * The application should now be running on `localhost:3000` diff --git a/docker-compose.yml b/docker-compose.yml index 4bb729b..a07dbb6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,33 +8,20 @@ services: context: . container_name: wakapi environment: - - WAKAPI_DB_USER=wakapi - - WAKAPI_DB_PASSWORD=supersecretpassword - - WAKAPI_DB_HOST=wakapi_db - - WAKAPI_DB_NAME=wakapi_db + - WAKAPI_DB_TYPE=sqlite3 + - WAKAPI_DB_USER= + - WAKAPI_DB_PASSWORD= + - WAKAPI_DB_HOST= + - WAKAPI_DB_NAME=/data/wakapi.db + - WAKAPI_DEFAULT_USER_NAME=admin + - WAKAPI_DEFAULT_USER_PASSWORD=admin ports: - "3000:3000" - depends_on: - - wakapi_db - wakapi_db: - image: linuxserver/mariadb - container_name: wakapi_db - environment: - - PUID=1000 - - PGID=1000 - - MYSQL_ROOT_PASSWORD=rootpass - - TZ=Europe/London - - MYSQL_DATABASE=wakapi_db - - MYSQL_USER=wakapi - - MYSQL_PASSWORD=supersecretpassword - restart: unless-stopped - ports: - - "3306:3306" volumes: - - "dbdata:/config" + - wakapi_data:/data volumes: - dbdata: + wakapi_data: \ No newline at end of file diff --git a/wait-for-it.sh b/wait-for-it.sh index 5ad0333..50b69f5 100755 --- a/wait-for-it.sh +++ b/wait-for-it.sh @@ -1,4 +1,9 @@ -echo "Waiting 10 Seconds for DB to start" -sleep 10; +#!/bin/bash + +if [ "$WAKAPI_DB_TYPE" != "sqlite3" ]; then + echo "Waiting 10 Seconds for DB to start" + sleep 10; +fi + echo "Starting Application" ./wakapi \ No newline at end of file