Skip to content

Commit 08a06ce

Browse files
committed
fly deploy
1 parent a7ce3e5 commit 08a06ce

File tree

4 files changed

+43
-15
lines changed

4 files changed

+43
-15
lines changed

apps/proxy/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Adjust NODE_VERSION as desired
44
ARG NODE_VERSION=20.16.0
5-
FROM node:${NODE_VERSION}-bookworm as base
5+
FROM node:${NODE_VERSION}-bookworm AS base
66

77
LABEL fly_launch_runtime="NodeJS"
88

@@ -13,7 +13,7 @@ WORKDIR /app
1313
ENV NODE_ENV=production
1414

1515
# Build S3FS
16-
FROM base as build-s3fs
16+
FROM base AS build-s3fs
1717

1818
# Install dependencies
1919
RUN apt-get update && \
@@ -28,7 +28,7 @@ RUN git clone https://github.com/supabase/s3fs-fuse.git --branch s3/support-endp
2828
make install
2929

3030
# Build app
31-
FROM base as build-app
31+
FROM base AS build-app
3232

3333
# Install packages needed to build node modules
3434
RUN apt-get update -qq && \

apps/proxy/README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,32 @@ To stop all Docker containers, run:
8484
docker compose down
8585
```
8686

87-
## Deployment
87+
## Deploying to fly.io
8888

89-
The proxy is deployed on Fly.io.
89+
1. Create a new app if it doesn't exist
9090

91-
A Tigris bucket is used to store the DB tarballs and the TLS certificates.
91+
```shell
92+
fly apps create postgres-new-proxy
93+
```
94+
95+
2. Set the appropriate environment variables and secrets for the app "postgres-new-proxy" (see `.env.example`) in fly.io UI.
96+
97+
3. Allocate a dedicated IPv4 address for the app, it's required to resolve wildcard DNS queries correctly.
98+
99+
```shell
100+
fly ips allocate-v4
101+
```
102+
103+
4. On Cloudflare, add a new CNAME DNS record pointing to the Fly.io app domain:
104+
105+
| Type | Name | Value |
106+
| --- | --- | --- |
107+
| CNAME | *.db | postgres-new-proxy.fly.dev |
108+
109+
5. Deploy the app
110+
111+
Due to a bug in `fly` ignoring `.dockerignore` files when setting up a build context, we need to copy the file to the root of the repo and remove it after the deploy.
112+
113+
```shell
114+
cp .dockerignore ../.. && fly deploy ../.. --config apps/proxy/fly.toml && rm ../../.dockerignore
115+
```

apps/proxy/fly.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ app = 'postgres-new-proxy'
22

33
primary_region = 'iad'
44

5+
[build]
6+
dockerfile = "Dockerfile"
7+
ignorefile = ".dockerignore"
8+
59
[[services]]
610
internal_port = 5432
711
protocol = "tcp"

apps/proxy/tools/certbot/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ The certificates will be generated in `/mnt/s3/tls`.
3232

3333
1. Create a new app if it doesn't exist
3434

35-
```shell
36-
fly apps create postgres-new-certbot
37-
```
35+
```shell
36+
fly apps create postgres-new-certbot
37+
```
3838

3939
2. Build and deploy the Docker image to fly.io image registry
4040

41-
```shell
42-
fly deploy --build-only --push --image-label latest
43-
```
41+
```shell
42+
fly deploy --build-only --push --image-label latest
43+
```
4444

4545
3. Set the appropriate environment variables and secrets for the app "postgres-new-certbot" (see `.env.example`) in fly.io UI.
4646

4747
4. Deploy the machine with a schedule
4848

49-
```shell
50-
fly machine run registry.fly.io/postgres-new-certbot:latest "./certbot.sh" --region iad --schedule weekly
51-
```
49+
```shell
50+
fly machine run registry.fly.io/postgres-new-certbot:latest "./certbot.sh" --region iad --schedule weekly
51+
```
5252

5353
The machine will now be started weekly in order to renew the certificates.
5454

0 commit comments

Comments
 (0)