From 714a0402956268e0b28d68e6b4ac6a9bbdc14e71 Mon Sep 17 00:00:00 2001 From: mr-karan Date: Fri, 12 Jul 2019 07:24:02 +0530 Subject: [PATCH 1/6] fix: Add listmonk binary to Gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7259656..170e1a3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ frontend/yarn.lock config.toml node_modules +listmonk \ No newline at end of file From bdc837d03f7c35193e76b3e63a357c4ce1183165 Mon Sep 17 00:00:00 2001 From: mr-karan Date: Fri, 12 Jul 2019 07:24:33 +0530 Subject: [PATCH 2/6] feat: Create docker release - Updates `.goreleaser.yml` to add docker build step - Adds `Dockerfile` for listmonk - Adds `docker-compose.yml` for reference. --- .goreleaser.yml | 12 ++++++++++++ Dockerfile | 6 ++++++ docker-compose.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.goreleaser.yml b/.goreleaser.yml index d344779..649d0bf 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -27,3 +27,15 @@ archives: - config.toml.sample - README.md - LICENSE +dockers: + - + goos: linux + goarch: amd64 + binaries: + - listmonk + image_templates: + - "knadh/listmonk:latest" + - "knadh/listmonk:{{ .Tag }}" + dockerfile: Dockerfile + extra_files: + - config.toml.sample diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6b55692 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM alpine:latest AS deploy +RUN apk --no-cache add ca-certificates +COPY listmonk / +COPY config.toml.sample /etc/listmonk/config.toml +VOLUME ["/etc/listmonk"] +CMD ["./listmonk", "--config", "/etc/listmonk/config.toml"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e093f31 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,42 @@ +# NOTE: This docker-compose.yml is meant to be just an example guideline +# on how you can achieve the same. It is not intented to run out of the box +# and you must edit the below configurations to suit your needs. + +version: "3.7" + +services: + db: + image: postgres:11 + ports: + - "5432:5432" + volumes: + - type: volume + source: listmonk-data + target: /var/lib/postgresql/data + networks: + - listmonk + environment: + - POSTGRES_PASSWORD=listmonk + - POSTGRES_USER=listmonk + - POSTGRES_DB=listmonk + restart: unless-stopped + + app: + restart: unless-stopped + depends_on: + - db + image: knadh/listmonk:latest + volumes: + - type: bind + source: ./config.toml + target: /etc/listmonk/config.toml + ports: + - "9000:9000" + networks: + - listmonk + +networks: + listmonk: + +volumes: + listmonk-data: From 3ed39a4f569f70404a968dda31a3199515408efd Mon Sep 17 00:00:00 2001 From: mr-karan Date: Fri, 12 Jul 2019 07:51:48 +0530 Subject: [PATCH 3/6] feat: Add docker instructions --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 49312e8..962a7b1 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,14 @@ listmonk is a standalone, self-hosted, newsletter and mailing list manager. It i - Visit `http://localhost:9000`. - Since there is no user auth yet, it's best to put listmonk behind a proxy like Nginx and setup basicauth on all endpoints except for the few endpoints that need to be public. Here is a [sample nginx config](https://github.com/knadh/listmonk/wiki/Production-Nginx-config) for production use. +### 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 --config /etc/listmonk/config.toml` to setup the DB. +- Visit `http://localhost:9000`. + ### Help and docs [Help and documentation](https://listmonk.app/docs) (work in progress). From 51ec37427f8e36a24ad0fb9581fdd84e60ef5d10 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Fri, 12 Jul 2019 11:24:43 +0530 Subject: [PATCH 4/6] Add install readme file --- .goreleaser.yml | 2 +- INSTALL.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 INSTALL.md diff --git a/.goreleaser.yml b/.goreleaser.yml index 649d0bf..74251a8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -24,8 +24,8 @@ builds: archives: - format: tar.gz files: - - config.toml.sample - README.md + - INSTALL.md - LICENSE dockers: - diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..14ef5c5 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,5 @@ +# Install and run + +- 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. +- Visit `http://localhost:9000`. From 728d1c26e739b5bc3cc4f881f218e302b27469da Mon Sep 17 00:00:00 2001 From: karan Date: Fri, 12 Jul 2019 13:50:44 +0530 Subject: [PATCH 5/6] feat: Add docker demo setup --- .goreleaser.yml | 5 +++-- Dockerfile | 8 ++++---- INSTALL.md | 17 +++++++++++++++++ README.md | 4 +++- config.toml.sample | 4 ++-- docker-compose.yml | 45 ++++++++++++++++++++++++++++----------------- 6 files changed, 57 insertions(+), 26 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 74251a8..8c30623 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,5 +1,6 @@ env: - GO111MODULE=on + - CGO_ENABLED=0 - RELEASE_BUILDS=dist/listmonk_darwin_amd64/listmonk dist/listmonk_linux_amd64/listmonk dist/listmonk_windows_amd64//listmonk.exe before: @@ -34,8 +35,8 @@ dockers: binaries: - listmonk image_templates: - - "knadh/listmonk:latest" - - "knadh/listmonk:{{ .Tag }}" + - "listmonk/listmonk:latest" + - "listmonk/listmonk:{{ .Tag }}" dockerfile: Dockerfile extra_files: - config.toml.sample diff --git a/Dockerfile b/Dockerfile index 6b55692..9f37f8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:latest AS deploy RUN apk --no-cache add ca-certificates -COPY listmonk / -COPY config.toml.sample /etc/listmonk/config.toml -VOLUME ["/etc/listmonk"] -CMD ["./listmonk", "--config", "/etc/listmonk/config.toml"] +WORKDIR /listmonk +COPY listmonk . +COPY config.toml.sample config.toml +CMD ["./listmonk"] diff --git a/INSTALL.md b/INSTALL.md index 14ef5c5..525b252 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -3,3 +3,20 @@ - 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. - 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. diff --git a/README.md b/README.md index 962a7b1..eee7321 100644 --- a/README.md +++ b/README.md @@ -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. - `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`. +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 documentation](https://listmonk.app/docs) (work in progress). diff --git a/config.toml.sample b/config.toml.sample index 1b9f12b..8ac6561 100644 --- a/config.toml.sample +++ b/config.toml.sample @@ -46,10 +46,10 @@ max_send_errors = 1000 # Database. [db] -host = "localhost" +host = "demo-db" port = 5432 user = "listmonk" -password = "" +password = "listmonk" database = "listmonk" ssl_mode = "disable" diff --git a/docker-compose.yml b/docker-compose.yml index e093f31..cc99b51 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,15 +4,18 @@ version: "3.7" -services: - db: +x-app-defaults: &app-defaults + restart: unless-stopped + image: listmonk/listmonk:latest + ports: + - "9000:9000" + networks: + - listmonk + +x-db-defaults: &db-defaults image: postgres:11 ports: - - "5432:5432" - volumes: - - type: volume - source: listmonk-data - target: /var/lib/postgresql/data + - "9432:5432" networks: - listmonk environment: @@ -21,19 +24,27 @@ services: - POSTGRES_DB=listmonk restart: unless-stopped +services: + db: + <<: *db-defaults + volumes: + - type: volume + source: listmonk-data + target: /var/lib/postgresql/data + app: - restart: unless-stopped + <<: *app-defaults depends_on: - db - image: knadh/listmonk:latest - volumes: - - type: bind - source: ./config.toml - target: /etc/listmonk/config.toml - ports: - - "9000:9000" - networks: - - listmonk + + demo-db: + <<: *db-defaults + + demo-app: + <<: *app-defaults + command: [sh, -c, "yes | ./listmonk --install && ./listmonk"] + depends_on: + - demo-db networks: listmonk: From 1534c4678a3026c29c55e524a12756e494d2580b Mon Sep 17 00:00:00 2001 From: karan Date: Fri, 12 Jul 2019 15:21:30 +0530 Subject: [PATCH 6/6] fix: Path for windows build in goreleaser --- .gitignore | 2 +- .goreleaser.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 170e1a3..6a9a8f8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ frontend/yarn.lock config.toml node_modules -listmonk \ No newline at end of file +listmonk diff --git a/.goreleaser.yml b/.goreleaser.yml index 8c30623..071cd2b 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,7 +1,7 @@ env: - 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: hooks: