Skip to content

Commit

Permalink
Merge pull request #8 from itishrishikesh/dockerize
Browse files Browse the repository at this point in the history
docker-compose file added
  • Loading branch information
itishrishikesh authored Dec 13, 2023
2 parents dbb8677 + a1d9701 commit 2e8c378
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# syntax=docker/dockerfile:1

# Build the application from source
FROM golang:1.19 AS build-stage

WORKDIR /app
Expand All @@ -17,6 +14,12 @@ FROM gcr.io/distroless/base-debian11 AS build-release-stage

WORKDIR /

COPY ./sql/schema ./

CMD ["go", "install", "github.com/pressly/goose/v3/cmd/goose@latest"]

CMD ["goose", "postgres", "$GO_FEED_DB_URL", "up"]

COPY --from=build-stage /docker-gs-ping /docker-gs-ping

EXPOSE 8080
Expand Down
28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
services:
gofeed:
build:
context: .
dockerfile: Dockerfile
ports:
- 8080:80
depends_on:
- goose
environment:
- GO_FEED_DB_URL=postgres://gofeed:gofeed@postgres:5432/gofeed?sslmode=disable
- PORT=8080
postgres:
image: postgres:15.4
restart: always
environment:
- POSTGRES_USER=gofeed
- POSTGRES_PASSWORD=gofeed
- POSTGRES_DB=gofeed
ports:
- "15432:5432"
volumes:
- /sql/.nocode
healthcheck:
test: ["CMD-SHELL", "pg_isready -d gofeed -U gofeed"]
interval: 10s
timeout: 5s
retries: 5
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {
log.Fatal("E#1OLYW6 - PORT is not found in the env variables")
}

dbUrl := os.Getenv("DB_URL")
dbUrl := os.Getenv("GO_FEED_DB_URL")
if dbUrl == "" {
log.Fatal("E#1ORGYA - DB_URL is not found in the env variables")
}
Expand Down

0 comments on commit 2e8c378

Please sign in to comment.