Skip to content

Commit

Permalink
Add docker-compose based setup for local dev (#581)
Browse files Browse the repository at this point in the history
* add docker-compose based setup for local dev

- pdns (auth + resolver)
- postgresql

* add ipfs docker container

* doc / config updates

* env.yaml -> server.yaml
  • Loading branch information
walkah authored Mar 14, 2022
1 parent a9d1a4e commit 8c77c7b
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 56 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ result
yesod-devel/*
addon-manifest.json
env.yaml
server.yaml
domain-key.txt
domain-crt.txt

Expand Down Expand Up @@ -587,4 +588,5 @@ MigrationBackup/

# End of https://www.gitignore.io/api/vim,emacs,sublimetext,visualstudio


fission-web-server/data/
fission-web-server/.env
29 changes: 29 additions & 0 deletions fission-web-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,32 @@ $ psql
```

Migrations will be performed automatically when running the server

### Using Docker

To mimic the full "fission stack" for local development, you can use the included `docker-compose.yml`. This assumes that you have Docker installed locally:

1. Copy the env.example file to `.env` (these values are used by docker compose). Edit as desired (defaults will work)
2. Start docker compose: `docker compose up -d`. This will start postgres, ipfs and powerdns containers, including a local DNS resolver.
3. Create the three necessary zones (specified in `.env`):
- `docker compose exec dns-auth pdnsutil create-zone runfission.test`
- `docker compose exec dns-auth pdnsutil create-zone fissionuser.test`
- `docker compose exec dns-auth pdnsutil create-zone fissionapp.test`
4. Point your local DNS resolver to localhost.
- on macOS: this is under System Preferences > Network > Advanced.
- on Linux: Add `nameserver 127.0.0.1` to `/etc/resolv.conf`

You can now build / run the haskell server. The included `server.yaml.example` is configured to work with the local docker setup.

#### Local DNS troubleshooting

To make sure your local DNS setup is working, try running: `dig runfission.test`. You should see a response containing:

```
runfission.test. 3600 IN SOA a.misconfigured.dns.server.invalid. hostmaster.runfission.test. 0 10800 3600 604800 3600
```

If you don't see that, you can try the following steps:
1. Ensure the local DNS server is set up for the zone, e.g. `dig runfission.test -p 5300 @127.0.0.1`. If that fails, make sure the zone is created (see above).
2. Ensure the local resolver is working, e.g. `dig runfission.test @127.0.0.1`. If that fails, make sure the zone exists in `.env`.
3. If `dig runfission.test` still fails, ensure your system is set to use the local resolver. Also, try disabling any VPN software (Tailscale, etc) as they may conflict with DNS resolution.
45 changes: 45 additions & 0 deletions fission-web-server/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: "3"
services:
postgres:
image: postgres:11-alpine
env_file: .env
ports:
- 5432:5432
volumes:
- ./data/postgres:/var/lib/postgresql/data
dns-auth:
image: powerdns/pdns-auth-44
command: --local-address=0.0.0.0 --local-port=5300
user: root
env_file: .env
ports:
- "5300:5300"
- "5300:5300/udp"
- "8081:8081"
networks:
default:
ipv4_address: 172.25.0.6
dns-recursor:
image: powerdns/pdns-recursor-44
command: --forward-zones=${BASE_DOMAIN}=172.25.0.6:5300,${USER_DOMAIN}=172.25.0.6:5300,${APP_DOMAIN}=172.25.0.6:5300 --forward-zones-recurse=.=1.1.1.1 --local-address=0.0.0.0 --local-port=53
env_file: .env
ports:
- "53:53"
- "53:53/udp"
- "8082:8082" # HTTP API for the recursor
ipfs:
image: ipfs/go-ipfs:v0.11.0
ports:
- "4001:4001"
- "5001:5001"
- "8080:8080"
volumes:
- ./data/ipfs:/data/ipfs
networks:
default:
driver: bridge
ipam:
config:
# defining the network range and IP for the authoritative server is only necessary in
# specific cases (e.g. to avoid breaking networking on some servers, most do fine without)
- subnet: 172.25.0.0/16
8 changes: 8 additions & 0 deletions fission-web-server/env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=web_api
PDNS_RECURSOR_API_KEY=changeme
PDNS_AUTH_API_KEY=changeme
BASE_DOMAIN=runfission.test
USER_DOMAIN=fissionuser.test
APP_DOMAIN=fissionapp.test
52 changes: 0 additions & 52 deletions fission-web-server/env.yaml.example

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ runInProd overrideVerbose action = do
putStrLnIO " 📥 Loading Heroku addon manifest..."
Just manifest <- JSON.decodeFileStrict "./addon-manifest.json"

putStrLnIO " 📥 Loading the Fission Server's env.yaml"
env <- YAML.decodeFileThrow "./env.yaml"
putStrLnIO " 📥 Loading the Fission Server's server.yaml"
env <- YAML.decodeFileThrow "./server.yaml"

let
AWS.Environment {..} = env |> aws
Expand Down
2 changes: 1 addition & 1 deletion fission-web-server/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: fission-web-server
version: "2.18.0.0"
version: "2.19.0.0"
category: API
author:
- Brooklyn Zelenka
Expand Down
57 changes: 57 additions & 0 deletions fission-web-server/server.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
web:
host: http://runfission.test
port: 1337
tls: false
environment: localhost
pretty: true
monitor: false
useEKG: false
zone_id: runfission.test.

ipfs:
timeout: 10
urls:
- http://localhost:5001
remotePeers:
- /ip4/127.0.0.1/tcp/4001/p2p/12D3KooWMQSgdfa4tUrDhkFx4zP3ZpgT1ryj9KH5RGUae62Vsc7y

storage:
stripe_count: 4
conns_per_stripe: 50
conn_ttl: 10
postgresql:
host: localhost
database: web_api
username: postgres
password: postgres

auth:
fission_did: did:key:z6MkgYGF3thn8k1Fv4p4dWXKtsXCnLH7q9yw4QgNPULDmDKB

aws:
mock_route53: true
access_key: FAKEKEY
secret_key: FAKEKEY
zone_id: FAKE

pdns:
api_url: http://localhost:8081
api_key: changeme

fission_file_system:
base_user_data_root_domain: fissionuser.test
base_user_data_zone_id: fissionuser.test.
default_data_cid: Qmc5m94Gu7z62RC8waSKkZUrCCBJPyHbkpmGzEePxy2oXJ # empty string

web_app:
base_domain_name: fissionapp.test
base_aws_zone_id: fissionapp.test.
placeholder_cid: QmRVvvMeMEPi1zerpXYH9df3ATdzuB63R1wf3Mz5NS5HQN # Fission logo on a blank page
live_drive_url: drive.fission.codes

send_in_blue:
api_key: xkeysib-KEY
base_url: https://api.sendinblue.com
verification_email_template_id: 17
recovery_email_template_id: 26
recovery_app_url: https://dashboard.fission.codes/recover/

0 comments on commit 8c77c7b

Please sign in to comment.