-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58d4ae8
commit 6bf535d
Showing
3 changed files
with
75 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM golang:1.16-buster AS builder | ||
|
||
WORKDIR /src/app | ||
|
||
# install system dependencies | ||
RUN apt-get update \ | ||
&& apt-get -y install netcat \ | ||
&& apt-get clean | ||
|
||
COPY go.* ./ | ||
RUN go mod download | ||
COPY . . | ||
|
||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o dblab . | ||
|
||
FROM scratch AS bin | ||
|
||
LABEL org.opencontainers.image.documentation="https://github.com/danvergara/dblab" \ | ||
org.opencontainers.image.source="https://github.com/danvergara/dblab" \ | ||
org.opencontainers.image.title="dblab" | ||
|
||
COPY --from=builder /src/app/dblab /bin/dblab |
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,33 @@ | ||
version: "3.9" | ||
|
||
services: | ||
postgres: | ||
image: postgres:12.1-alpine | ||
environment: | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_DB=users | ||
ports: | ||
- '5432:5432' | ||
networks: | ||
- dblab | ||
|
||
dblab: | ||
build: | ||
context: . | ||
target: builder | ||
depends_on: | ||
- postgres | ||
environment: | ||
- DB_HOST=postgres | ||
- DB_USER=postgres | ||
- DB_PASSWORD=password | ||
- DB_NAME=users | ||
- DB_PORT=5432 | ||
- DB_DRIVER=postgres | ||
entrypoint: ["/bin/bash", "./scripts/entripoint.dev.sh"] | ||
networks: | ||
- dblab | ||
|
||
networks: | ||
dblab: |
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,17 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo "Waiting for postgres..." | ||
|
||
while ! nc -z postgres 5432; do | ||
sleep 0.1 | ||
done | ||
|
||
echo "PostgreSQL started" | ||
|
||
echo "Runinng the migrations against the DB" | ||
go run cmd/dbmigrate/main.go | ||
|
||
echo "Seeding the database" | ||
go run cmd/seeder/main.go seed |