Skip to content

Commit

Permalink
Add docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
olivertso authored and junkert committed Dec 23, 2019
1 parent cc23b6e commit 184e9c6
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ docs/demos/dellstore2/dellstore2-normal-1.0

# Test files
db_test_*.log
output.Test*

# Test coverage
coverage.out

# IntelliJ Idea
.idea

# Demo SQL/Log files
docs/demos/dellstore2/*.sql
docs/demos/dellstore2/*.log

49 changes: 49 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: "3.7"

services:
bin:
build:
context: .
target: gonymizer
volumes:
- type: bind
source: ./testing
target: /go/testing
depends_on:
- db

test:
build:
context: .
target: build
command:
- go
- test
- -v
- -cover
- -coverprofile=coverage.out
- -run
- TestStart
environment:
POSTGRES_HOST: db
POSTGRES_USER: gonymizer
volumes:
- type: bind
source: ./testing
target: /tmp/gonymizer/testing
depends_on:
- db

db:
image: postgres:11-alpine
ports:
- 5432:5432
environment:
POSTGRES_USER: gonymizer
volumes:
- type: volume
source: dbdata
target: /var/lib/postgresql/data

volumes:
dbdata:
7 changes: 6 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ var (

// GetTestDbConf will return a PGConfig for the specified localhost testing database.
func GetTestDbConf(dbName string) PGConfig {
host, ok := os.LookupEnv("POSTGRES_HOST")
if !ok {
host = "localhost"
}
conf := PGConfig{}
conf.Host = "localhost"
conf.Username = os.Getenv("POSTGRES_USER")
conf.Host = host
conf.DefaultDBName = dbName
conf.SSLMode = "disable"
return conf
Expand Down
5 changes: 5 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e

docker-compose run --rm "$@"

0 comments on commit 184e9c6

Please sign in to comment.