diff --git a/.gitignore b/.gitignore index 02975b8ac..0d8414746 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ result yesod-devel/* addon-manifest.json env.yaml +server.yaml domain-key.txt domain-crt.txt @@ -587,4 +588,5 @@ MigrationBackup/ # End of https://www.gitignore.io/api/vim,emacs,sublimetext,visualstudio - +fission-web-server/data/ +fission-web-server/.env diff --git a/fission-web-server/README.md b/fission-web-server/README.md index 21137d243..ae1089e54 100644 --- a/fission-web-server/README.md +++ b/fission-web-server/README.md @@ -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. \ No newline at end of file diff --git a/fission-web-server/docker-compose.yml b/fission-web-server/docker-compose.yml new file mode 100644 index 000000000..28370550f --- /dev/null +++ b/fission-web-server/docker-compose.yml @@ -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 diff --git a/fission-web-server/env.example b/fission-web-server/env.example new file mode 100644 index 000000000..d0bbef77e --- /dev/null +++ b/fission-web-server/env.example @@ -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 diff --git a/fission-web-server/env.yaml.example b/fission-web-server/env.yaml.example deleted file mode 100644 index 37e15420f..000000000 --- a/fission-web-server/env.yaml.example +++ /dev/null @@ -1,52 +0,0 @@ -server: - host: http://localhost - port: 1337 - tls: false - pretty: true - zone_id: Z1ABCDEF - -ipfs: - url: http://localhost:5001 - timeout: 3600 - urls: - - node.runfission.com:5001 - remotePeers: - - /dns4/node.runfission.com/tcp/4001/ipfs/QmVLEz2SxoNiFnuyLpbXsH6SvjPTrHNMU88vCQZyhgBzgw - -storage: - stripe_count: 4 - conns_per_stripe: 50 - conn_ttl: 10 - postgresql: - host: localhost - database: web_api - -auth: - fission_did: did:key:z6MkgYGF3thn8k1Fv4p4dWXKtsXCnLH7q9yw4QgNPULDmDKB - -aws: - mock_route53: true - # access_key: - # secret_key: - # zone_id: - -pdns: - api_url: http://localhost:8081 - api_key: FAKE_API_KEY - -fission_file_system: - base_user_data_root_domain: fission.name - base_user_data_zone_id: ABCDEF - default_data_cid: Qmc5m94Gu7z62RC8waSKkZUrCCBJPyHbkpmGzEePxy2oXJ # empty string - -web_app: - base_app_domain_name: fission.app - base_user_data_zone_id: ABCDEF - app_placeholder_cid: QmRVvvMeMEPi1zerpXYH9df3ATdzuB63R1wf3Mz5NS5HQN # Fission logo on a blank page - -send_in_blue: - api_key: xkeysib-KEY - base_url: https://api.sendinblue.com - verification_email_template_id: 0 - recovery_email_template_id: 0 - recovery_app_url: https://dashboard.fission.codes/recover/ diff --git a/fission-web-server/library/Fission/Web/Server/Internal/Production.hs b/fission-web-server/library/Fission/Web/Server/Internal/Production.hs index 499bd0513..bbe43c248 100644 --- a/fission-web-server/library/Fission/Web/Server/Internal/Production.hs +++ b/fission-web-server/library/Fission/Web/Server/Internal/Production.hs @@ -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 diff --git a/fission-web-server/package.yaml b/fission-web-server/package.yaml index d5ccfb882..3cf9516dc 100644 --- a/fission-web-server/package.yaml +++ b/fission-web-server/package.yaml @@ -1,5 +1,5 @@ name: fission-web-server -version: "2.18.0.0" +version: "2.19.0.0" category: API author: - Brooklyn Zelenka diff --git a/fission-web-server/server.yaml.example b/fission-web-server/server.yaml.example new file mode 100644 index 000000000..e558df587 --- /dev/null +++ b/fission-web-server/server.yaml.example @@ -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/