@@ -0,0 +1 @@
|
||||
!config.toml
|
||||
@@ -0,0 +1,62 @@
|
||||
# Docker suite for development
|
||||
|
||||
**NOTE**: This exists only for local development. If you are interested in using
|
||||
Docker for a production setup, see the installation page in the docs
|
||||
(`docs/docs/content/installation.md`) 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
|
||||
|
||||
### Verify your config file
|
||||
|
||||
The config file provided at `dev/config.toml` will be used when running the
|
||||
containerized development stack. Make sure the values set within are suitable
|
||||
for the feature you're trying to develop.
|
||||
|
||||
### Setup DB
|
||||
|
||||
Running this will build the appropriate images and initialize the database.
|
||||
|
||||
```bash
|
||||
make init-dev-docker
|
||||
```
|
||||
|
||||
### Start frontend and backend apps
|
||||
|
||||
Running this start your local development stack.
|
||||
|
||||
```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.
|
||||
@@ -0,0 +1,11 @@
|
||||
FROM golang:1.24.1 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
|
||||
CMD [ "sleep infinity" ]
|
||||
@@ -0,0 +1,24 @@
|
||||
[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"
|
||||
|
||||
# Database.
|
||||
[db]
|
||||
host = "db"
|
||||
port = 5432
|
||||
user = "eaglecast-dev"
|
||||
password = "eaglecast-dev"
|
||||
|
||||
# Ensure that this database has been created in Postgres.
|
||||
database = "eaglecast-dev"
|
||||
|
||||
ssl_mode = "disable"
|
||||
max_open = 25
|
||||
max_idle = 25
|
||||
max_lifetime = "300s"
|
||||
|
||||
# Optional space separated Postgres DSN params. eg: "application_name=eaglecast gssencmode=disable"
|
||||
params = ""
|
||||
@@ -0,0 +1,71 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
adminer:
|
||||
image: adminer:4.8.1-standalone
|
||||
restart: always
|
||||
ports:
|
||||
- 8070:8080
|
||||
networks:
|
||||
- eaglecast-dev
|
||||
|
||||
mailhog:
|
||||
image: mailhog/mailhog:v1.0.1
|
||||
ports:
|
||||
- "1025:1025" # SMTP
|
||||
- "8025:8025" # UI
|
||||
networks:
|
||||
- eaglecast-dev
|
||||
|
||||
db:
|
||||
image: postgres:13
|
||||
ports:
|
||||
- "5432:5432"
|
||||
networks:
|
||||
- eaglecast-dev
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=eaglecast-dev
|
||||
- POSTGRES_USER=eaglecast-dev
|
||||
- POSTGRES_DB=eaglecast-dev
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- type: volume
|
||||
source: eaglecast-dev-db
|
||||
target: /var/lib/postgresql/data
|
||||
|
||||
front:
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: dev/app.Dockerfile
|
||||
command: ["make", "run-frontend"]
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
- EAGLECAST_API_URL=http://backend:9000
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
- ../:/app
|
||||
networks:
|
||||
- eaglecast-dev
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: dev/app.Dockerfile
|
||||
command: ["make", "run-backend-docker"]
|
||||
ports:
|
||||
- "9000:9000"
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
- ../:/app
|
||||
- ${GOPATH:-${HOME}/go}/pkg/mod/cache:/go/pkg/mod/cache
|
||||
networks:
|
||||
- eaglecast-dev
|
||||
|
||||
volumes:
|
||||
eaglecast-dev-db:
|
||||
|
||||
networks:
|
||||
eaglecast-dev:
|
||||
Reference in New Issue
Block a user