Skip to content

Commit

Permalink
Merge branch 'master' into issue40-internal-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rngadam authored Jan 11, 2020
2 parents 6539e84 + d9c8c67 commit 0c21bbb
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:alpine as build-deps
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install

FROM node:alpine

WORKDIR /usr/src/app
COPY --from=build-deps /usr/src/app/node_modules /usr/src/app/node_modules
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
76 changes: 75 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ npm start
install PostgreSQL extensions:

```bash
pip install pgxnclient
pgxn install pgtap
```

Expand All @@ -33,6 +34,7 @@ this will also run the test suite.
## run test suite on changes

```bash
brew install fswatch
./watch-test.sh timesheet
```

Expand Down Expand Up @@ -73,4 +75,76 @@ database:

```bash
pg_dump -N postgraphql_watch -O -s postgresql://localhost/timesheet > sql/timesheet.sql
```
```

## deploying to Heroku

Because Heroku requires the app to be in the root, we use subtree to push:

```bash
git subtree push --prefix server heroku master
```

Creating/updating schema on Heroku instance:

```bash
psql -v "ON_ERROR_STOP=1" -b -1 -e -f sql/PSQL.sql `heroku pg:credentials:url | tail -1`
```

Restarting the dyno (to load changes to the database for example)

```bash
heroku restart -a coderbunker-timesheet
```

## data transfer to/from heroku

Pushing the local database:

```bash
heroku pg:push timesheet postgresql-rigid-65921 --app coderbunker-timesheet
```

Pulling the Heroku database locally and making a copy before changing the pulled version
(adjust date):

```bash
heroku pg:pull postgresql-rigid-65921 heroku-timesheet --app coderbunker-timesheet
psql -c 'CREATE DATABASE "heroku-timesheet-20180416" TEMPLATE "heroku-timesheet";' postgres
```

## Containerization

- Build Image: `docker build -t timesheet-backend .`

- Run Container: `docker run -p 3000:3000 -e DATABASE_URL=postgres://docker.for.mac.localhost/DATABASE_NAME timesheet-backend`

## Manage Domain

### CNAME Setup for Heroku app

1. Get CNAME from heroku: `heroku domains -a coderbunker-timesheet`

2. add CNAME to google domains

| NAME | TYPE | TTL | DATA |
|--------|:--------------:|------:|--------------------------------------:|
| data | CNAME | 1h | data.coderbunker.com.herokudns.com. |


### SSL Setup

Enable SSL automatically managed by heroku.

## troubleshooting

want to push an amended history with subtree push? sadly, does not support push.

create a local branch and force push that first:

```
git subtree split --prefix server -b backup-branch
git push -f heroku backup-branch:master
```

should now be back to normal...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# timesheet-backend
Timesheet data warehouse backend

See [[INSTALL.md]] for setup
See [INSTALL.md](./INSTALL.md) for setup

# timesheet data warehouse

Expand Down
12 changes: 12 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:alpine as build-deps
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install

FROM node:alpine

WORKDIR /usr/src/app
COPY --from=build-deps /usr/src/app/node_modules /usr/src/app/node_modules
COPY . .
EXPOSE 3000
CMD ["npm", "start"]

0 comments on commit 0c21bbb

Please sign in to comment.