Skip to content

Commit

Permalink
feat: docker deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
SShlykov committed Mar 18, 2024
1 parent 49eebe0 commit a770b21
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 158 deletions.
11 changes: 11 additions & 0 deletions api_gateway.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.22-alpine as server
WORKDIR /app

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

COPY .. .

RUN go build -o /app/main ./api_gateway/cmd/api_gateway

CMD [ "/app/main" ]
2 changes: 1 addition & 1 deletion api_gateway/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ include .env
export

run:
go run ./cmd/gateway/main.go
go run ./cmd/api_gateway/main.go
File renamed without changes.
2 changes: 1 addition & 1 deletion bookback/Dockerfile → auth.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ RUN go mod download

COPY .. .

RUN go build -o /app/main ./cmd/bookback
RUN go build -o /app/main ./auth/cmd/auth

CMD [ "/app/main" ]
32 changes: 0 additions & 32 deletions auth/.dockerignore

This file was deleted.

72 changes: 0 additions & 72 deletions auth/Dockerfile

This file was deleted.

50 changes: 0 additions & 50 deletions auth/compose.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion auth/pkg/grpc/user_v1/user_v1.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions bookback.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.22-alpine as builder
WORKDIR /app

COPY ./api_gateway ./api_gateway
COPY ./auth ./auth
COPY ./bookback ./bookback
COPY ./logger ./logger
COPY ./metrics ./metrics
COPY ./postgres ./postgres
COPY ./scripts ./scripts
COPY ./go.work ./go.work

RUN go build -o /app/main ./bookback/cmd/bookback

FROM alpine:3.12
WORKDIR /app

COPY --from=builder /app/main /app/main
COPY --from=builder /app/bookback/config /app/config

CMD [ "/app/main" ]
1 change: 0 additions & 1 deletion deployments/docker-compose.yml

This file was deleted.

78 changes: 78 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
version: "3.8"


services:
# auth:
# build:
# dockerfile: auth.Dockerfile
# container_name: auth
# restart: always
# hostname: auth
# env_file:
# - ./auth/.env
# deploy:
# resources:
# limits:
# cpus: '2'
# memory: 250M
# logging:
# driver: "json-file"
# options:
# max-size: "50m"
# healthcheck:
# test: [ "CMD", "curl", "-f", "http://localhost:" ]
# interval: 1m30s
# timeout: 10s
# retries: 3
# start_period: 2m

bookback:
build:
context: .
dockerfile: bookback.Dockerfile
container_name: bookback
restart: always
hostname: bookback
env_file:
- ./bookback/.env
deploy:
resources:
limits:
cpus: '2'
memory: 250M
logging:
driver: "json-file"
options:
max-size: "50m"
# healthcheck:
# test: [ "CMD", "curl", "-f", "http://localhost:" ]
# interval: 3s
# retries: 5
# start_period: 30s

# api_gateway:
# build:
# dockerfile: api_gateway.Dockerfile
# container_name: api_gateway
# restart: always
# hostname: api_gateway
# env_file:
# - ./api_gateway/.env
# deploy:
# resources:
# limits:
# cpus: '2'
# memory: 250M
# logging:
# driver: "json-file"
# options:
# max-size: "50m"
# healthcheck:
# test: [ "CMD", "curl", "-f", "http://localhost:" ]
# interval: 3s
# retries: 5
# start_period: 30s

networks:
backnet:
driver: bridge

0 comments on commit a770b21

Please sign in to comment.