Skip to content

Commit

Permalink
Fix outdated docker local dev suite (#2200)
Browse files Browse the repository at this point in the history
* deps(dev): Upgrade golang to 1.20 in dev Dockerfile

* feat(dev): Make dev's config.toml conform to prod's

* fix(dev): Use dev db credentials in config

* feat(dev): Add support for devcontainer

* docs: How to set up dev env in different ways
  • Loading branch information
flyotlin authored Dec 10, 2024
1 parent 97fde64 commit 98934e6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 15 deletions.
8 changes: 8 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "listmonk",
"dockerComposeFile": "../dev/docker-compose.yml",
"service": "backend",
"workspaceFolder": "/app",
"forwardPorts": [9000],
"postStartCommand": "make dist && ./listmonk --install --idempotent --yes --config dev/config.toml"
}
4 changes: 2 additions & 2 deletions dev/app.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17 AS go
FROM golang:1.20 AS go

FROM node:16 AS node

Expand All @@ -8,4 +8,4 @@ ENV CGO_ENABLED=0
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH

WORKDIR /app
ENTRYPOINT [ "" ]
CMD [ "sleep infinity" ]
16 changes: 6 additions & 10 deletions dev/config.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
# IMPORTANT: This configuration is meant for development only
### DO NOT USE IN PRODUCTION ###

[app]
# Interface and port where the app will run its webserver. The default value
# of localhost will only listen to connections from the current machine. To
# listen on all interfaces use '0.0.0.0'. To listen on the default web address
# port, use port 80 (this will require running with elevated permissions).
address = "0.0.0.0:9000"

# BasicAuth authentication for the admin dashboard. This will eventually
# be replaced with a better multi-user, role-based authentication system.
# IMPORTANT: Leave both values empty to disable authentication on admin
# only where an external authentication is already setup.
admin_username = "listmonk"
admin_password = "listmonk"

# Database.
[db]
host = "db"
port = 5432
user = "listmonk-dev"
password = "listmonk-dev"

# Ensure that this database has been created in Postgres.
database = "listmonk-dev"

ssl_mode = "disable"
max_open = 25
max_idle = 25
max_lifetime = "300s"

# Optional space separated Postgres DSN params. eg: "application_name=listmonk gssencmode=disable"
params = ""
10 changes: 10 additions & 0 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
version: "3"

services:
adminer:
image: adminer:4.8.1-standalone
restart: always
ports:
- 8070:8080
networks:
- listmonk-dev

mailhog:
image: mailhog/mailhog:v1.0.1
ports:
- "1025:1025" # SMTP
- "8025:8025" # UI
networks:
- listmonk-dev

db:
image: postgres:13
Expand Down
21 changes: 18 additions & 3 deletions docs/docs/content/developer-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,24 @@ The app has two distinct components, the Go backend and the VueJS frontend. In t

### Running the dev environment
1. Run `make run` to start the listmonk dev server on `:9000`.
2. Run `make run-frontend` to start the Vue frontend in dev mode using yarn on `:8080`. All `/api/*` calls are proxied to the app running on `:9000`. Refer to the [frontend README](https://github.com/knadh/listmonk/blob/master/frontend/README.md) for an overview on how the frontend is structured.
3. Visit `http://localhost:8080`
You can run your dev environment locally or inside containers.

After setting up the dev environment, you can visit `http://localhost:8080`.


1. Locally
- Run `make run` to start the listmonk dev server on `:9000`.
- Run `make run-frontend` to start the Vue frontend in dev mode using yarn on `:8080`. All `/api/*` calls are proxied to the app running on `:9000`. Refer to the [frontend README](https://github.com/knadh/listmonk/blob/master/frontend/README.md) for an overview on how the frontend is structured.

2. Inside containers (Using Makefile)
- Run `make init-dev-docker` to setup container for db.
- Run `make dev-docker` to setup docker container suite.
- Run `make rm-dev-docker` to clean up docker container suite.

3. Inside containers (Using devcontainer)
- Open repo in vscode, open command palette, and select "Dev Containers: Rebuild and Reopen in Container".

It will set up db, and start frontend/backend for you.


# Production build
Expand Down

0 comments on commit 98934e6

Please sign in to comment.