-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #608 from mr-karan/dev_docker
feat: Add dev docker setup
- Loading branch information
Showing
4 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Docker suite for development | ||
|
||
**NOTE**: This exists only for local development. If you're interested in using Docker for a production setup, visit the [docs](https://listmonk.app/docs/installation/#docker) instead. | ||
|
||
### Objective | ||
|
||
The purpose of this docker suite for local development is to isolate all the dev dependencies in a docker environment. The containers have a host volume mounted inside for the entire app directory. This helps us to not do a full `docker build` for every single local change, only restarting the docker environment is enough. | ||
|
||
## Setting up a dev suite | ||
|
||
To spin up a local suite of | ||
|
||
- PostgreSQL | ||
- Mailhog | ||
- Node.js frontend app | ||
- Golang backend app | ||
|
||
### Setup DB | ||
|
||
```bash | ||
make init-dev-docker | ||
``` | ||
|
||
### Start frontend and backend apps | ||
|
||
```bash | ||
make dev-docker | ||
``` | ||
|
||
Visit `http://localhost:8080` on your browser. | ||
|
||
### Tear down | ||
|
||
This will tear down all the data, including DB. | ||
|
||
```bash | ||
make rm-dev-docker | ||
``` | ||
|
||
### See local changes in action | ||
|
||
- Backend: Anytime you do a change to the Go app, it needs to be compiled. Just run `make dev-docker` again and that should automatically handle it for you. | ||
- Frontend: Anytime you change the frontend code, you don't need to do anything. Since `yarn` is watching for all the changes and we have mounted the code inside the docker container, `yarn` server automatically restarts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM golang:1.17 AS go | ||
|
||
FROM node:16 AS node | ||
|
||
COPY --from=go /usr/local/go /usr/local/go | ||
ENV GOPATH /go | ||
ENV CGO_ENABLED=0 | ||
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH | ||
|
||
WORKDIR /app | ||
ENTRYPOINT [ "" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
version: "3" | ||
|
||
services: | ||
mailhog: | ||
image: mailhog/mailhog:v1.0.1 | ||
ports: | ||
- "1025:1025" # SMTP | ||
- "8025:8025" # UI | ||
|
||
db: | ||
image: postgres:13 | ||
ports: | ||
- "5432:5432" | ||
networks: | ||
- listmonk-dev | ||
environment: | ||
- POSTGRES_PASSWORD=listmonk-dev | ||
- POSTGRES_USER=listmonk-dev | ||
- POSTGRES_DB=listmonk-dev | ||
restart: unless-stopped | ||
volumes: | ||
- type: volume | ||
source: listmonk-dev-db | ||
target: /var/lib/postgresql/data | ||
|
||
front: | ||
build: | ||
context: ../ | ||
dockerfile: dev/app.Dockerfile | ||
command: ["make", "run-frontend"] | ||
ports: | ||
- "8080:8080" | ||
environment: | ||
- LISTMONK_API_URL=http://backend:9000 | ||
depends_on: | ||
- db | ||
volumes: | ||
- ../:/app | ||
networks: | ||
- listmonk-dev | ||
|
||
backend: | ||
build: | ||
context: ../ | ||
dockerfile: dev/app.Dockerfile | ||
command: ["make", "run-backend-docker"] | ||
ports: | ||
- "9000:9000" | ||
depends_on: | ||
- db | ||
volumes: | ||
- ../:/app | ||
- $GOPATH/pkg/mod/cache:/go/pkg/mod/cache | ||
networks: | ||
- listmonk-dev | ||
|
||
volumes: | ||
listmonk-dev-db: | ||
|
||
networks: | ||
listmonk-dev: |