Skip to content

Commit

Permalink
chore: adding app to the docker-compose & update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
anqorithm committed Sep 1, 2023
1 parent 5564956 commit 1932c07
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ DB_USER=
DB_PASSWORD=
DB_NAME=
DB_PORT=
API_KEY=
ACCESS_TOKEN_AUTH=
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
## Movies

## Prerequisites

1. Golang go1.20.7
2. Docker
3. Access Token Auth (You need to get a one from IMDB API)

## Overview

This is a service for gitting the latest movies from IMDB API, feed the database with the latest movies and expose it throgh a gRPC connection. This service fetches a new movie from IMDB every 3 seconds and if the latest movie is not exists in the database it will insert it into the database.

## Important commands to compile the protocol buffers

```sh

$ export PATH="$PATH:$(go env GOPATH)/bin"
$ protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative proto/movies.proto

```

## Fill the ".env" file

```
DB_HOST=
DB_USER=
DB_PASSWORD=
DB_NAME=
DB_PORT=
ACCESS_TOKEN_AUTH=
```

## How to run?

```
$ docker-compose up
```
18 changes: 18 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
version: '3.9'

services:
app:
build:
context: .
dockerfile: ./docker/Dockerfile
ports:
- 50051:50051
networks:
- movies
depends_on:
- postgres
postgres:
image: postgres
ports:
Expand All @@ -11,6 +21,8 @@ services:
POSTGRES_DB: movies
volumes:
- ./postgres_data:/var/lib/postgresql/data
networks:
- movies
pgadmin:
image: dpage/pgadmin4
ports:
Expand All @@ -21,5 +33,11 @@ services:
PGADMIN_LISTEN_PORT: 80
depends_on:
- postgres
networks:
- movies
volumes:
postgres_data:


networks:
movies:
15 changes: 15 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.20

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -o /movies

EXPOSE 50051

CMD ["/movies"]

0 comments on commit 1932c07

Please sign in to comment.