Skip to content

Commit

Permalink
Docker compose (jarun#417)
Browse files Browse the repository at this point in the history
* feat(docker): add healthcheck to container

Signed-off-by: Ameya Shenoy <[email protected]>

* feat(docker): add docker-compose files

Signed-off-by: Ameya Shenoy <[email protected]>
  • Loading branch information
codingCoffee authored and jarun committed Sep 24, 2019
1 parent ef2dd19 commit 4e13df9
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM python:alpine

MAINTAINER Ameya Shenoy "[email protected]"

ENV BUKUSERVER_PORT=5001

COPY . /Buku

RUN set -ex \
Expand All @@ -17,6 +19,9 @@ RUN set -ex \
&& apk del .build-deps \
&& rm -rf /Buku

ENTRYPOINT gunicorn --bind 0.0.0.0:5001 "bukuserver.server:create_app()"
EXPOSE 5001
HEALTHCHECK --interval=1m --timeout=10s \
CMD nc -z localhost ${BUKUSERVER_PORT} || exit 1

ENTRYPOINT gunicorn --bind 0.0.0.0:${BUKUSERVER_PORT} "bukuserver.server:create_app()"
EXPOSE ${BUKUSERVER_PORT}

31 changes: 31 additions & 0 deletions bukuserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [From PyPi](#from-pypi)
- [From source](#from-source)
- [Using Docker](#using-docker)
- [Using Docker Compose](#using-docker-compose)
- [Webserver options](#webserver-options)
- [Configuration](#configuration)
- [Screenshots](#screenshots)
Expand Down Expand Up @@ -57,6 +58,36 @@ database.

Visit `127.0.0.1:5001` in your browser to access your bookmarks.

#### Using Docker Compose

There is a `docker-compose.yml` file present in the `docker-compose` directory
in the root of this project. You may modify the configurations in this file to
your liking, and then simply execute the below command.

```sh
docker-compose up -d
```

You will have you bukuserver running on port port 80 of the host.

To stop simply run

```sh
docker-compose down
```

In case you want to add basic auth to your hosted instance you may do so by
creating a `.htpasswd` file in the `data/basic_auth` directory. Add a user to
the file using

```sh
htpasswd -c data/basic_auth/.htpasswd your_username
```

And then comment out the basic auth lines from the `data/nginx/nginx.conf` file.

For more information please refer the [nginx docs](https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/).

### Webserver options

To run the server on host 127.0.0.1, port 5001, run following command:
Expand Down
22 changes: 22 additions & 0 deletions docker-compose/data/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
server {
listen 80;
server_name yoursitename.com;
server_tokens off;

location /.well-known/acme-challenge/ {
root /var/www/certbot;
}

location / {
#auth_basic "Administrator's Area";
#auth_basic_user_file /basic_auth/.htpasswd;
proxy_pass http://bukuserver:5001;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Remote-Port $remote_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}

26 changes: 26 additions & 0 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3.7'

services:
bukuserver:
image: bukuserver/bukuserver
restart: unless-stopped
environment:
- BUKUSERVER_PER_PAGE=100
- BUKUSERVER_OPEN_IN_NEW_TAB=true
# - BUKUSERVER_SECRET_KEY=123456789012345678901234
# - BUKUSERVER_URL_RENDER_MODE=full
# - BUKUSERVER_DISABLE_FAVICON=false
ports:
- "5001:5001"
volumes:
- ./data:/root/.local/share/buku

nginx:
image: nginx:alpine
restart: unless-stopped
ports:
- "80:80"
volumes:
- ./data/nginx:/etc/nginx/conf.d
- ./data/basic_auth:/basic_auth

0 comments on commit 4e13df9

Please sign in to comment.