Skip to content

Commit

Permalink
Merge pull request #57 from Caknoooo/task/create-docker-compose-imple…
Browse files Browse the repository at this point in the history
…mentation

feat: docker implementation
  • Loading branch information
Caknoooo authored Dec 31, 2023
2 parents 3621632 + 8709d12 commit 20f3d0c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
DB_HOST = localhost
DB_HOST = <your host>
DB_USER = postgres
DB_PASS = <your password>
DB_NAME = <your database name>
DB_PORT = 5432

NGINX_PORT=8080
GOLANG_PORT=8888

SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SENDER_NAME="Go.Gin.Template <[email protected]>"
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM golang:alpine

RUN apk update && apk upgrade && \
apk add --no-cache bash

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . .

RUN go build -o main .

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

EXPOSE 8888

CMD ["air"]
41 changes: 41 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.9'

services:
postgres:
hostname: postgres
image: postgres:latest
ports:
- ${DB_PORT}:5432
volumes:
- ./volumes/postgres:/var/lib/postgresql/data
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASS}
- POSTGRES_DB=${DB_NAME}
networks:
- app-network

app:
hostname: app
container_name: golang-clean-template
build:
context: .
dockerfile: Dockerfile
ports:
- ${GOLANG_PORT}:${GOLANG_PORT}
restart: always
volumes:
- ./:/app
depends_on:
- postgres
env_file:
- .env
networks:
- app-network

volumes:
app_vol:

networks:
app-network:
driver: bridge

0 comments on commit 20f3d0c

Please sign in to comment.