Skip to content

Commit

Permalink
update dockerfile to include migrations dir
Browse files Browse the repository at this point in the history
Also, mention it in the README
  • Loading branch information
lfborjas committed Jan 30, 2021
1 parent bd35e7e commit 0ec166d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ RUN apt-get update && apt-get install -y libpq-dev postgresql-client-12
RUN adduser geocode-city-api
USER geocode-city-api

COPY --from=build /opt/geocode-city-api/migrations /opt/geocode-city-api/migrations
COPY --from=build /opt/geocode-city-api/bin /opt/geocode-city-api

WORKDIR /opt/geocode-city-api
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@ is that for the hyperloglog entries to "fall off" as we reach max memory, I'm us
heroku redis:maxmemory REDIS-NAME --policy allkeys-lru -a geocode-city
```

#### Database migrations (Heroku specific)

I _should_ set up a [`release` phase](https://devcenter.heroku.com/articles/container-registry-and-runtime#release-phase) to [run migrations automatically](https://devcenter.heroku.com/articles/release-phase). However, I'd rather not have that overhead for something that
happens somewhat seldom, so I instead use a [one-off dyno](https://devcenter.heroku.com/articles/container-registry-and-runtime#one-off-dynos):

```sh
> heroku run bash -a geocode-city
Running bash on ⬢ geocode-city... up, run.7528 (Hobby)
~ $ pwd
/opt/geocode-city-api
~ $ ls
geocode-city-api-exe migrations
~ $ ./geocode-city-api-exe --migrate
Initializing schema
NOTICE: relation "schema_migrations" already exists, skipping
Ok: 202101182025_geonames_raw.sql
Ok: 202101182130_non_city_tables.sql
Ok: 202101182140_city_table.sql
Ok: 202101182150_ft_and_indexes.sql
Ok: 202101191900_api_keys_table.sql
Ok: 202101201800_materialize_autocomplete.sql
Ok: 202101231600_api_quotas.sql
Execute: 202101301530_full_text_autocomplete.sql
All migrations ran.
```

## Development

Expand Down

0 comments on commit 0ec166d

Please sign in to comment.