generated from OtusGolang/home_work
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from dmitryt/hw12_13_14_15_calendar
Hw12 13 14 15 calendar
- Loading branch information
Showing
48 changed files
with
1,671 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM golang:1.14-alpine AS builder | ||
|
||
RUN apk update | ||
|
||
# Set necessary environmet variables needed for our image | ||
ENV GO111MODULE=on \ | ||
CGO_ENABLED=0 \ | ||
GOOS=linux | ||
|
||
WORKDIR /build | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
# Copy the code into the container | ||
COPY . . | ||
|
||
ARG MAIN_FILE_PATH | ||
|
||
# Build the application | ||
RUN go build -o main $MAIN_FILE_PATH | ||
RUN chmod +x main | ||
|
||
# Build a small image | ||
FROM scratch | ||
|
||
COPY --from=builder /build/main / | ||
EXPOSE 8081 | ||
|
||
# Command to run | ||
ENTRYPOINT ["/main"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GRPC_ADDRESS=0.0.0.0:50051 | ||
HTTP_ADDRESS=0.0.0.0:50052 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
DB_HOST=db | ||
DB_PORT=5432 | ||
DB_USER=db_calendar_user | ||
DB_PASSWORD=test | ||
DB_NAME=db_calendar | ||
DB_REPO_TYPE=psql | ||
DB_ITEMS_PER_QUERY=50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DB_NAME=db_calendar_test |
10 changes: 10 additions & 0 deletions
10
hw12_13_14_15_calendar/deployments/docker-compose.prod.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: "2.4" | ||
|
||
services: | ||
db: | ||
volumes: | ||
- pg_volume:/var/lib/postgresql/data | ||
|
||
volumes: | ||
pg_volume: | ||
driver: local |
20 changes: 20 additions & 0 deletions
20
hw12_13_14_15_calendar/deployments/docker-compose.test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: "2.4" | ||
|
||
services: | ||
db: | ||
environment: | ||
- POSTGRES_DB=db_calendar_test | ||
migrator: | ||
env_file: | ||
- database_test.env | ||
calendar: | ||
env_file: | ||
- database_test.env | ||
calendar_scheduler: | ||
env_file: | ||
- database_test.env | ||
- queue_test.env | ||
calendar_sender: | ||
env_file: | ||
- database_test.env | ||
- queue_test.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
version: "2.4" | ||
|
||
services: | ||
db: | ||
image: postgres:12 | ||
environment: | ||
- POSTGRES_USER=db_calendar_user | ||
- POSTGRES_PASSWORD=test | ||
- POSTGRES_DB=db_calendar | ||
ports: | ||
- "5432:5432" | ||
healthcheck: | ||
test: ["CMD", "pg_isready", "-U", "$POSTGRES_USER"] | ||
interval: 10s | ||
timeout: 10s | ||
retries: 3 | ||
start_period: 20s | ||
migrator: | ||
build: | ||
context: ../ | ||
dockerfile: ./deployments/migrator/Dockerfile | ||
env_file: | ||
- database.env | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
queue: | ||
build: | ||
context: ./rabbitmq | ||
environment: | ||
- RABBITMQ_DEFAULT_USER=guest | ||
- RABBITMQ_DEFAULT_PASS=guest | ||
healthcheck: | ||
test: [ "CMD", "nc", "-z", "localhost", "5672" ] | ||
interval: 10s | ||
timeout: 10s | ||
retries: 3 | ||
start_period: 20s | ||
ports: | ||
- "5672:5672" | ||
- "15672:15672" | ||
calendar: | ||
build: | ||
context: ../ | ||
dockerfile: ./deployments/Dockerfile | ||
args: | ||
- MAIN_FILE_PATH=cmd/calendar/main.go | ||
env_file: | ||
- database.env | ||
- logger.env | ||
- api.env | ||
environment: | ||
- PORT=8081 | ||
volumes: | ||
- ../migrations:/migrations | ||
ports: | ||
- "8888:50052" | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
calendar_scheduler: | ||
build: | ||
context: ../ | ||
dockerfile: ./deployments/Dockerfile | ||
args: | ||
- MAIN_FILE_PATH=cmd/calendar_scheduler/main.go | ||
env_file: | ||
- database.env | ||
- logger.env | ||
- queue.env | ||
volumes: | ||
- ../migrations:/migrations | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
queue: | ||
condition: service_healthy | ||
calendar_sender: | ||
build: | ||
context: ../ | ||
dockerfile: ./deployments/Dockerfile | ||
args: | ||
- MAIN_FILE_PATH=cmd/calendar_sender/main.go | ||
env_file: | ||
- database.env | ||
- logger.env | ||
- queue.env | ||
volumes: | ||
- ../migrations:/migrations | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
queue: | ||
condition: service_healthy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
LOG_LEVEL=debug | ||
LOG_FILE=calendar.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM golang:1.14-alpine | ||
|
||
RUN apk update | ||
|
||
ENV GO111MODULE=on \ | ||
CGO_ENABLED=0 \ | ||
GOOS=linux | ||
|
||
WORKDIR /build | ||
|
||
# install goose | ||
RUN go get 'github.com/pressly/goose/cmd/goose' | ||
|
||
# mount the app | ||
RUN mkdir -p /opt/db | ||
COPY ./migrations /opt/db/migrations | ||
|
||
# define goose as the entrypoint | ||
ENTRYPOINT /go/bin/goose -v -dir /opt/db/migrations postgres "host=$DB_HOST port=$DB_PORT user=$DB_USER password=$DB_PASSWORD dbname=$DB_NAME sslmode=disable" up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
QUEUE_URI=amqp://guest:guest@queue:5672/ | ||
QUEUE_NAME=events | ||
QUEUE_SCAN_TIMEOUT_MS=10000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
QUEUE_NAME=events-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM rabbitmq:3-management | ||
RUN apt-get update | ||
RUN apt-get install -y netcat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.