feat: Add docker demo setup

This commit is contained in:
karan 2019-07-12 13:50:44 +05:30
parent 51ec37427f
commit 728d1c26e7
6 changed files with 57 additions and 26 deletions

View File

@ -1,5 +1,6 @@
env: env:
- GO111MODULE=on - GO111MODULE=on
- CGO_ENABLED=0
- RELEASE_BUILDS=dist/listmonk_darwin_amd64/listmonk dist/listmonk_linux_amd64/listmonk dist/listmonk_windows_amd64//listmonk.exe - RELEASE_BUILDS=dist/listmonk_darwin_amd64/listmonk dist/listmonk_linux_amd64/listmonk dist/listmonk_windows_amd64//listmonk.exe
before: before:
@ -34,8 +35,8 @@ dockers:
binaries: binaries:
- listmonk - listmonk
image_templates: image_templates:
- "knadh/listmonk:latest" - "listmonk/listmonk:latest"
- "knadh/listmonk:{{ .Tag }}" - "listmonk/listmonk:{{ .Tag }}"
dockerfile: Dockerfile dockerfile: Dockerfile
extra_files: extra_files:
- config.toml.sample - config.toml.sample

View File

@ -1,6 +1,6 @@
FROM alpine:latest AS deploy FROM alpine:latest AS deploy
RUN apk --no-cache add ca-certificates RUN apk --no-cache add ca-certificates
COPY listmonk / WORKDIR /listmonk
COPY config.toml.sample /etc/listmonk/config.toml COPY listmonk .
VOLUME ["/etc/listmonk"] COPY config.toml.sample config.toml
CMD ["./listmonk", "--config", "/etc/listmonk/config.toml"] CMD ["./listmonk"]

View File

@ -3,3 +3,20 @@
- Run `./listmonk --new-config` to generate a sample `config.toml` and add your configuration (SMTP and Postgres DB credentials primarily). - Run `./listmonk --new-config` to generate a sample `config.toml` and add your configuration (SMTP and Postgres DB credentials primarily).
- `./listmonk --install` to setup the DB. - `./listmonk --install` to setup the DB.
- Visit `http://localhost:9000`. - Visit `http://localhost:9000`.
## Running on Docker
You can checkout the [docker-compose.yml](docker-compose.yml) to get an idea of how to run `listmonk` with `PostgreSQL` together using Docker.
- `docker-compose up -d` to run all the services together.
- `docker-compose run --rm app ./listmonk --install` to setup the DB.
- Visit `http://localhost:9000`.
### Demo Setup
`docker-compose.yml` includes a demo setup to quickly try out `listmonk`. It spins up PostgreSQL and listmonk app containers without any persistent data.
- Run `docker-compose up -d demo-db demo-app`.
- Visit `http://localhost:9000`.
_NOTE_: This setup will delete the data once you kill and remove the containers. This setup is NOT intended for production use.

View File

@ -19,9 +19,11 @@ listmonk is a standalone, self-hosted, newsletter and mailing list manager. It i
You can checkout the [docker-compose.yml](docker-compose.yml) to get an idea of how to run `listmonk` with `PostgreSQL` together using Docker. You can checkout the [docker-compose.yml](docker-compose.yml) to get an idea of how to run `listmonk` with `PostgreSQL` together using Docker.
- `docker-compose up -d` to run all the services together. - `docker-compose up -d` to run all the services together.
- `docker-compose run --rm app ./listmonk --install --config /etc/listmonk/config.toml` to setup the DB. - `docker-compose run --rm app ./listmonk --install` to setup the DB.
- Visit `http://localhost:9000`. - Visit `http://localhost:9000`.
Alternatively, to run a demo of listmonk, you can quickly spin up a container `docker-compose up -d demo-db demo-app`. NOTE: This doesn't persist Postgres data after you stop and remove the container, this setup is intended only for demo. _DO NOT_ use the demo setup in production.
### Help and docs ### Help and docs
[Help and documentation](https://listmonk.app/docs) (work in progress). [Help and documentation](https://listmonk.app/docs) (work in progress).

View File

@ -46,10 +46,10 @@ max_send_errors = 1000
# Database. # Database.
[db] [db]
host = "localhost" host = "demo-db"
port = 5432 port = 5432
user = "listmonk" user = "listmonk"
password = "" password = "listmonk"
database = "listmonk" database = "listmonk"
ssl_mode = "disable" ssl_mode = "disable"

View File

@ -4,15 +4,18 @@
version: "3.7" version: "3.7"
services: x-app-defaults: &app-defaults
db: restart: unless-stopped
image: listmonk/listmonk:latest
ports:
- "9000:9000"
networks:
- listmonk
x-db-defaults: &db-defaults
image: postgres:11 image: postgres:11
ports: ports:
- "5432:5432" - "9432:5432"
volumes:
- type: volume
source: listmonk-data
target: /var/lib/postgresql/data
networks: networks:
- listmonk - listmonk
environment: environment:
@ -21,19 +24,27 @@ services:
- POSTGRES_DB=listmonk - POSTGRES_DB=listmonk
restart: unless-stopped restart: unless-stopped
services:
db:
<<: *db-defaults
volumes:
- type: volume
source: listmonk-data
target: /var/lib/postgresql/data
app: app:
restart: unless-stopped <<: *app-defaults
depends_on: depends_on:
- db - db
image: knadh/listmonk:latest
volumes: demo-db:
- type: bind <<: *db-defaults
source: ./config.toml
target: /etc/listmonk/config.toml demo-app:
ports: <<: *app-defaults
- "9000:9000" command: [sh, -c, "yes | ./listmonk --install && ./listmonk"]
networks: depends_on:
- listmonk - demo-db
networks: networks:
listmonk: listmonk: