This repository contains:
- All backend server side code, mostly written in Golang.
- All public facing web sites, specifically the administrative site and the non-authenticated frontend.
- PostgreSQL schema and sample/seed data.
- Install docker, nodejs, and yarn.
sudo apt-get install docker.io docker-compose nodejs
npm install -g yarn
- Configure docker
sudo gpasswd -a $USER docker
newgrp docker
docker ps -a # testing
- Ensure you have the latest golang (>1.12)
- Install nodejs/npm (https://nodejs.org/en/download/)
- Install docker (https://docs.docker.com/docker-for-mac/install/)
- Ensure you have the latest golang (>1.12)
- Establish a default developer setup.
make
This will create a default fieldkit.env
for you as well as materialize the various secrets.js
files.
- Run the database.
make restart-postgres
➜ cloud git:(master) make restart-postgres
docker-compose stop postgres
docker-compose rm -f postgres
No stopped containers
docker-compose up -d postgres
Creating cloud_postgres_1 ... done
- Run the server.
./run-server.sh
This builds and runs the server outside of a docker container. This means that PostgreSQL is usually the only docker container running.
➜ cloud git:(master) ./run-server-containerless.sh
+ export FIELDKIT_ADDR=:8080
+ FIELDKIT_ADDR=:8080
+ export 'FIELDKIT_POSTGRES_URL=postgres://fieldkit:[email protected]/fieldkit?sslmode=disable'
+ FIELDKIT_POSTGRES_URL='postgres://fieldkit:[email protected]/fieldkit?sslmode=disable'
+ export FIELDKIT_DISABLE_MEMORY_LOGGING=true
+ FIELDKIT_DISABLE_MEMORY_LOGGING=true
+ export FIELDKIT_DISABLE_STARTUP_REFRESH=true
+ FIELDKIT_DISABLE_STARTUP_REFRESH=true
+ export FIELDKIT_API_DOMAIN=127.0.0.1:8080
+ FIELDKIT_API_DOMAIN=127.0.0.1:8080
+ export FIELDKIT_API_HOST=http://127.0.0.1:8080
+ FIELDKIT_API_HOST=http://127.0.0.1:8080
+ '[' -f aws.env ']'
+ make server
cp server/inaturalist/secrets.go.template server/inaturalist/secrets.go
cd server && env GOOS=linux GOARCH=amd64 go build -o /Users/jlewallen/fieldkit/cloud/build/server server.go
go: finding github.com/pkg/errors v0.0.0-20190227000051-27936f6d90f9
go: finding github.com/hashicorp/go-immutable-radix v0.0.0-20180129170900-7f3cd4390caa
go: finding github.com/dghubble/sling v0.0.0-20170219194632-91b015f8c5e2
go: finding github.com/aws/aws-sdk-go v0.0.0-20170317202926-5b99715ae294
go: finding github.com/dghubble/oauth1 v0.0.0-20170219195226-3c7784d12fed
go: finding github.com/armon/go-metrics v0.0.0-20180713145231-3c58d8115a78
go: finding github.com/PyYoshi/goa-logging-zap v0.2.3
# Lots and lots more Golang packages.
+ build/server
2019-08-06T10:57:31.864-0700 INFO fieldkit server/server.go:135 Starting
2019-08-06T10:57:31.864-0700 INFO fieldkit server/server.go:343 Selected {"archiver": "aws"}
2019-08-06T10:57:31.864-0700 INFO fieldkit.backend backend/concatenation.go:320 Worker starting
2019-08-06T10:57:31.891-0700 INFO fieldkit.jobs jobs/postgres.go:101 Listening {"queue": "messages"}
# More startup log messages...
- Run one of the web sites in development mode.
cd portal
npm run serve
DONE Compiled successfully
App running at:
- Local: http://localhost:8081/
- Network: http://192.168.0.3:8081/
Note that the development build is not optimized.
To create a production build, use yarn build.
We use this tool for database migrations:
https://github.com/golang-migrate/migrate/tree/master/cmd/migrate
- The link above has instructions on how to download the install the tool. Put the tool somewhere in your path.
- There’s a tool mkm.sh in this directory that will create a new migration with the name you’ve given. The file will create new up and down SQL files in the migrations directory.
- Just run make `migrate-up` to migrate your local database.
- To rerun a migration, run migrate-down and then you can re-run migrate-up.