Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: dockerfile and docker compose #5

Merged
merged 5 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
data
.env*
.dockerignore
.git*
*.md
cliff.toml
docker-compose.yaml
Dockerfile
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ==================== builder ====================
FROM golang:1.21.5-alpine as builder
WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . .

RUN go run github.com/google/wire/cmd/wire@latest ./...

RUN CGO_ENABLED=0 GOOS=linux go build cmd/main.go

# ==================== runner ====================
FROM alpine:latest as runner
WORKDIR /app

COPY --from=builder /app/main ./main

EXPOSE 3000

CMD ["./main"]
28 changes: 28 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3.9"

services:
db:
image: postgres:15.5-bookworm
container_name: oph66-db
environment:
POSTGRES_PASSWORD: "123456"
ports:
- 5432:5432
volumes:
- ./data/db:/var/lib/postgresql/data
networks:
- oph66

redis:
image: redis:7.2.3-bookworm
container_name: oph66-cache
command:
- redis-server
- --requirepass 123456
ports:
- 6379:6379
networks:
- oph66

networks:
oph66: {}
26 changes: 18 additions & 8 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
version: '3.9'
version: "3.9"

services:
db:
image: postgres:15.5-bookworm
container_name: oph66-db
environment:
POSTGRES_PASSWORD: '123456'
ports:
- 5432:5432
POSTGRES_PASSWORD: "123456"
volumes:
- ./data/db:/var/lib/postgresql/data
networks:
- oph66

redis:
image: redis:7.2.3-bookworm
container_name: oph66-cache
command:
- redis-server
- --requirepass 123456
ports:
- 6379:6379
networks:
- oph66

backend:
container_name: oph66-backend
build: .
ports:
- 3000:3000
environment:
- DB_URL=postgres://postgres:123456@oph66-db:5432/postgres
- REDIS_ADDR=oph66-cache
- REDIS_PORT=6379
- REDIS_PASSWORD=123456
- APP_PORT=3000
- APP_ENV=development
networks:
- oph66

networks:
oph66: {}
oph66: {}