Skip to content

Commit

Permalink
Merge pull request #32 from NikhilSharma03/update_dockerfile
Browse files Browse the repository at this point in the history
feat: update `docker compose` file
  • Loading branch information
NikhilSharma03 authored Dec 25, 2023
2 parents 7d32aaa + 8091799 commit 9ec2539
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 32 deletions.
42 changes: 42 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -buildvcs=false -o ./tmp/main ./cmd"
delay = 0
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = ["cmd"]
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
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 = true

[screen]
clear_on_rebuild = true
keep_scroll = true
13 changes: 12 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
cli
# git dir
.git
.github
assets

# environment vars
.env
.env.dev
.env.prod

# CLI dir
cli
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.env
.env
.env.dev
.env.prod
15 changes: 0 additions & 15 deletions Dockerfile

This file was deleted.

18 changes: 18 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG BUILD_IMAGE_TAG=1.19-bullseye

FROM golang:${BUILD_IMAGE_TAG}

WORKDIR /usr/src/app

COPY go.mod go.sum .

RUN go mod download

RUN go install github.com/cosmtrek/air@latest && \
go install github.com/go-delve/delve/cmd/dlv@latest

COPY . .

EXPOSE 8000

CMD ["air", "-c", ".air.toml"]
28 changes: 27 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## Proto files commands

.PHONY: generate-proto-protoc
generate-proto-protoc:
protoc -I ./api \
Expand All @@ -12,8 +14,32 @@ generate-proto:

.PHONY: clean-proto
clean-proto:
rm -rf pkg/protobuf pkg/google
rm -rf pkg/{protobuf,google}

.PHONY: run-server
run-server:
go run cmd/main.go

## Development Server docker-compose commands
DOCKER_COMPOSE_DEV_FILE=docker-compose-dev.yml
DOCKER_COMPOSE_DEV_SERVER_SERVICE=okane_api

.PHONY: compose-dev-build
compose-dev-build:
@echo "Running Okane API docker compose dev build"
docker compose -f $(DOCKER_COMPOSE_DEV_FILE) build

.PHONY: compose-dev-up
compose-dev-up:
@echo "Running Okane API docker compose dev up in detach mode"
docker compose -f $(DOCKER_COMPOSE_DEV_FILE) up -d

.PHONY: compose-dev-logs
compose-dev-logs:
@echo "Running Okane API docker compose dev logs"
docker compose -f $(DOCKER_COMPOSE_DEV_FILE) logs $(DOCKER_COMPOSE_DEV_SERVER_SERVICE) -f

.PHONY: compose-dev-down
compose-dev-down:
@echo "Running Okane API docker compose dev down"
docker compose -f $(DOCKER_COMPOSE_DEV_FILE) down
54 changes: 54 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: "3.9"

services:
okane_api:
container_name: okane_api
build:
context: .
dockerfile: Dockerfile.dev

volumes:
- type: bind
source: .
target: /usr/src/app

ports:
- "8000:8000"

env_file:
- '.env'

links:
- redis

depends_on:
- redis

networks:
- backend

restart: unless-stopped

redis:
container_name: redis
image: redis:6.2-alpine

command: redis-server --save 20 1 --loglevel warning --requirepass foobar

volumes:
- redis_data:/data

ports:
- "6379:6379"

networks:
- backend

restart: unless-stopped


volumes:
redis_data:

networks:
backend:
14 changes: 0 additions & 14 deletions docker-compose.yml

This file was deleted.

0 comments on commit 9ec2539

Please sign in to comment.