generated from OtusGolang/home_work
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Hw12 13 14 15 calendar #14
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d86cf34
HW-15 init
dmitryt 0e4b186
correct cfg
dmitryt 474223b
init docker-compose
dmitryt 99b2fa3
added tests
dmitryt c76adf9
code clean
dmitryt 8e8001c
Merge branch 'master' into hw12_13_14_15_calendar
dmitryt 9835e33
moved migrations to docker
dmitryt dc297ce
updated tests output
dmitryt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used this version of docker-compose to have an ability to use
healthcheck
together withdepends_on