Skip to content

Commit 23fa231

Browse files
maikelmclauflinevq
authored andcommitted
added migration files to dockerfile (#75)
1 parent 92674e3 commit 23fa231

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ env:
1717
global:
1818
- GO111MODULE=on
1919
- TEST_TAGS="integration"
20+
- DATABASE_MIGRATIONS_URL="file://$(pwd)/migrations"
2021
- secure: gGqNxojD1sfTk4qnFUTQ2vx5V9ryOLEctChxv6iZa1rxbyRE1cB65IPCFquU8Qo7rN4LcqlwpCvEfJHkRs41mOtrkBuRFUSMA1Z0wp6Gpz3jT7nvygRLfkcWMbfHDa2oKS6c9cTWlmanuGl8KWKxZrWzvl7WwtD0Rqfbr3cH74JmOfq5h05ermhE0YNFNKrnra2WZYQGeS9i/qh2nDvnuVw0nI6pXsGpl7fZ/bMDDUipCqSDtfRyV389UAUA5pab+BCp0/hLrDiUOL/xSB2zIoyenQ8mM01MpM1Hx2vh+PrbCJE880ON1374tPRkyNvPlQMeSYv+eZQBT8zxYsQ+xEmfxVvkqvyGo630X5trV5IVQqn+6xlyIFHwemLIpGqwZMg3DlQ2JujQGy6/xfvfd3tMdnzi6NoTtE1h5CYYJ168tnytAz4d3xJ7nGYl4zGejO4971c97JdUY078PYaKDkbRGA0pCk0MYmA9VnkcsPO9v6vW8kV09VFRgNKBJV0YNycWvdTLBF+i8Xe3/aAGMxfJLsbb+gYPTI4cQiIlIc7AlDpd7LzHUuUMQr8cCvK2IoJNnTsgyqtfZZBIbvJkZlEp6EjbKT0Wawh6oC0u+2+9LXYB4tuLDYkprA6NhN5bna4rh/uB826/BXhX6J5SpC4PzDlf985cazEGpyAwyQQ=
2122
- secure: OvxpTKJ4i+BefkUj52NgTmDXK5/Mm3zkIVyf13uXTEWrEXOs0aRsbxHCmQpHgTK4pMVXGeZ4WlUz7way0zi7QFNsW35dWfDUZ3DCUx7zkSpv10Voan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ZOb8wkgzdorZtdywUyqg1CPa8/poXnhRcaPEHjL5wzGsu9+yYFtNZ6HDcGTIAB4pkgePsfo52/t937dLQ+d3tQlPQpvdjsHkOThqhfqp0tsfB6n7vWfqRQj4F9WG6KhHjMDEx+C4eEAaslPs33hI6yTFW6M48aMnDfBIbMvHk=
@@ -29,8 +30,8 @@ install:
2930
before_script:
3031
- make lint
3132
script:
32-
- docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d vault
33+
- docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d vault
3334
- sleep 3
34-
- VAULT_TOKEN=$(docker logs grant-vault 2>&1 | grep "Root Token" | tail -1 | cut -d ' ' -f 3 ) docker-compose -f docker-compose.yml -f docker-compose.dev.yml run --rm web make
35+
- VAULT_TOKEN=$(docker logs grant-vault 2>&1 | grep "Root Token" | tail -1 | cut -d ' ' -f 3 ) docker-compose -f docker-compose.yml -f docker-compose.dev.yml run --rm web make
3536
after_script:
3637
- git diff-index --quiet HEAD --

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ CMD ["go", "run", "bin/grant-server/main.go"]
1010
FROM alpine:3.6
1111
RUN apk add --update ca-certificates # Certificates for SSL
1212
COPY --from=builder /src/grant-server /bin/
13+
COPY --from=builder /src/migrations/ /migrations/
1314
EXPOSE 3333
1415
CMD ["/bin/grant-server"]

docker-compose.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ networks:
77
services:
88
web:
99
container_name: grant-web
10-
image: grant-web-builder
10+
image: grant-web-builder
1111
build:
1212
context: .
13-
target: builder
13+
target: builder
1414
ports:
1515
- "3333:3333"
1616
environment:
1717
- "DATABASE_URL=postgres://grants:password@postgres/grants?sslmode=disable"
1818
- "LEDGER_SERVER=https://ledger-staging.mercury.basicattentiontoken.org"
1919
- "REDIS_URL=redis://redis:6379"
20+
- "DATABASE_MIGRATIONS_URL=file:///src/migrations"
2021
- BAT_SETTLEMENT_ADDRESS
2122
- CHALLENGE_BYPASS_SERVER=http://challenge-bypass:2416
2223
- CHALLENGE_BYPASS_TOKEN
@@ -62,6 +63,7 @@ services:
6263
environment:
6364
- "SENTRY_DSN"
6465
- "DATABASE_URL=postgres://btokens:password@challenge-bypass-postgres/btokens?sslmode=disable"
66+
- "DATABASE_MIGRATIONS_URL=file:///src/migrations"
6567
depends_on:
6668
- challenge-bypass-postgres
6769
networks:

promotion/datastore.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ func (pg *Postgres) NewMigrate() (*migrate.Migrate, error) {
5656
return nil, err
5757
}
5858

59+
dbMigrationsURL := os.Getenv("DATABASE_MIGRATIONS_URL")
5960
m, err := migrate.NewWithDatabaseInstance(
60-
"file:///src/migrations",
61-
"postgres", driver)
61+
dbMigrationsURL,
62+
"postgres",
63+
driver,
64+
)
6265
if err != nil {
6366
return nil, err
6467
}
@@ -290,10 +293,10 @@ func (pg *Postgres) ClaimForWallet(promotion *Promotion, wallet *wallet.Info, bl
290293
// GetAvailablePromotionsForWallet returns the list of available promotions for the wallet
291294
func (pg *Postgres) GetAvailablePromotionsForWallet(wallet *wallet.Info) ([]Promotion, error) {
292295
statement := `
293-
select
294-
promotions.*,
296+
select
297+
promotions.*,
295298
promotions.active and promotions.remaining_grants > 0 and (
296-
( promotions.promotion_type = 'ugp' and claims.id is null ) or
299+
( promotions.promotion_type = 'ugp' and claims.id is null ) or
297300
( ( promotion_type = 'ads' or promotions.version < 5 ) and claims.id is not null and not claims.redeemed )
298301
) as available
299302
from promotions left join claims on promotions.id = claims.promotion_id and claims.wallet_id = $1;`

0 commit comments

Comments
 (0)