Skip to content

Commit

Permalink
feat: dockerize apps
Browse files Browse the repository at this point in the history
  • Loading branch information
barbequeorbarbecue committed May 19, 2024
1 parent b1978d6 commit a9463c8
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ yarn-error.log*

# local env files
.env
.env*.local
.env*.*

# vercel
.vercel
Expand All @@ -40,4 +40,6 @@ yarn-error.log*
*.tsbuildinfo
pgdata

.turbo
.turbo

tmp/
51 changes: 51 additions & 0 deletions apps/discord-bot/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ./apps/discord-bot/cmd/main"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata", "apps/web", "apps/twitch-bot", "node_modules", "packages/senchabot-prisma"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[proxy]
app_port = 0
enabled = false
proxy_port = 0

[screen]
clear_on_rebuild = false
keep_scroll = true
15 changes: 15 additions & 0 deletions apps/discord-bot/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.22-alpine

WORKDIR /app

# Install CA certificates
RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates

RUN go install github.com/cosmtrek/air@latest

COPY go.mod go.sum ./
RUN go mod download

EXPOSE 8080

CMD ["air", "-c", "./apps/discord-bot/.air.toml"]
51 changes: 51 additions & 0 deletions apps/twitch-bot/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ./apps/twitch-bot/cmd/main"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata", "apps/web", "apps/discord-bot", "node_modules", "packages/senchabot-prisma"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[proxy]
app_port = 0
enabled = false
proxy_port = 0

[screen]
clear_on_rebuild = false
keep_scroll = true
15 changes: 15 additions & 0 deletions apps/twitch-bot/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.22-alpine

WORKDIR /app

# Install CA certificates
RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates

RUN go install github.com/cosmtrek/air@latest

COPY go.mod go.sum ./
RUN go mod download

EXPOSE 8080

CMD ["air", "-c", "./apps/twitch-bot/.air.toml"]
57 changes: 45 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,49 @@
version: "3"
services:
mysql:
container_name: senchabot_mysqldb
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
MYSQL_DATABASE: $MYSQL_DATABASE
MYSQL_USER: $MYSQL_USER
MYSQL_PASSWORD: $MYSQL_PASSWORD
postgres:
image: postgres:latest
container_name: senchabot_postgres_db
ports:
- "3306:3306"
- "${POSTGRES_DB_PORT:-5432}:5432"
volumes:
- mysql-data:/var/lib/mysql
- senchabot-postgres-data:/var/lib/postgresql/data
env_file:
- ./.env
pgAdmin:
image: dpage/pgadmin4
container_name: pgAdmin
env_file:
- ./.env
ports:
- "${PGADMIN_PORT:-5050}:80"
twitch-bot:
container_name: senchabot_twitch_bot
build:
dockerfile: ./apps/twitch-bot/Dockerfile.dev
context: .
ports:
- "${TWITCH_BOT_PORT:-8084}:8080"
volumes:
- ./:/app
env_file:
- ./apps/twitch-bot/.env
depends_on:
- postgres
discord-bot:
container_name: senchabot_discord_bot
build:
dockerfile: ./apps/discord-bot/Dockerfile.dev
context: .
ports:
- "${DISCORD_BOT_PORT:-8088}:8080"
volumes:
- ./:/app
env_file:
- ./apps/discord-bot/.env
depends_on:
- postgres

volumes:
mysql-data:
senchabot-postgres-data:

networks:
default:

0 comments on commit a9463c8

Please sign in to comment.