Host for free on Fly.io #537
Replies: 37 comments 113 replies
-
For sending emails, the following providers have free options:
|
Beta Was this translation helpful? Give feedback.
-
Awesome write! This will be an excellent resource for people getting into Pocketbase. Are you also going to add an entry in the FAQ linking here? I think that would be a good place, instead of people combing through the discussions for a solution. |
Beta Was this translation helpful? Give feedback.
-
Great! It would you really nice if you can also describe how can we get a data backup. Let's say access |
Beta Was this translation helpful? Give feedback.
-
Here's another Docker approach that builds a custom binary as part of Note: In theory, you should be able to cross-compile (#537 (reply in thread)) but if you don't know the target architecture or don't want to worry about it changing, this solution will work. 1. Create a custom PocketBase build:
// ./pocketbase.go
package main
import (
"log"
"github.com/pocketbase/pocketbase"
)
func main() {
app := pocketbase.New()
if err := app.Start(); err != nil {
log.Fatal(err)
}
} // ./go.mod
module pocketbase 2 Create the Dockerfile:FROM alpine:latest
RUN apk add -v build-base
RUN apk add -v go
RUN apk add -v ca-certificates
RUN apk add --no-cache \
unzip \
# this is needed only if you want to use scp to copy later your pb_data locally
openssh
# Copy your custom PocketBase and build
COPY ./pocketbase-custom /pb
WORKDIR /pb
# Note: This will pull the latest version of pocketbase. If you are just doing
# simple customizations and don't have a local build environment for Go,
# leave this line in.
# For more complex builds that include other dependencies, remove this
# line and rely on the go.sum lockfile.
RUN go get github.com/pocketbase/pocketbase
RUN go build
WORKDIR /
EXPOSE 8080
# start PocketBase
CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8080"] Let me know what you think! Tested and working on fly.io. |
Beta Was this translation helpful? Give feedback.
-
Deploy with Litestream with PocketBase as a FrameworkI just finished an example repo here https://github.com/TylerSustare/pocketbase-framework-litestream The biggest difference is using the Dockerfile to launch litestream with our custom Go binary as the sub process. |
Beta Was this translation helpful? Give feedback.
-
With fly workers you can turn the Pocketbase into Serverless if you use fly.io. There is a way to also do this on GCP Cloud Run also using volumes also. So if the app has no users then it shuts down ( which is configurable ). When a new request comes through it starts is back up in about half a second by simple rebooting the fire tacket instance and remounting the volume. Blog and example code here: It would be great to combine Serverless with S3 backup / restore but no one has gotten that far yet |
Beta Was this translation helpful? Give feedback.
-
Thanks for this guide! When i ran: |
Beta Was this translation helpful? Give feedback.
-
For anyone still following this, I added a reference to this discussion at https://github.com/benallfree/awesome-pocketbase. I think it would be great to maybe start adding Dockerfiles to awesome-pocketbase, perhaps that could be a centralized place where various configurations could live. |
Beta Was this translation helpful? Give feedback.
-
Hi, Thanks for this solution, but I'm trying to add my pb_data to Dockerfile without results. This is my Dockerfile
I just add
I've pb_data local directory in same Dockerfile directory, but when app is deployed, always show installer view. |
Beta Was this translation helpful? Give feedback.
-
Are there any other option besides fly.io because it needs credit card, and being student I don't have at all. @benallfree |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks for this helpful guide ✌️ I just want to add that now you can download your database using fly CLI. You can find more information here: https://fly.io/docs/flyctl/ssh-sftp-get/. To use this feature, navigate to your project's folder, where your |
Beta Was this translation helpful? Give feedback.
-
Hi. I can not use fly.io because of credit card. I'm trying to use render.com free web service but it fails. I don't know what's the problem. I just create a github repo with dockerfile and connected to render website. The logs says docker image is built and points to urls for admin & api s but above in dashboard says failed. |
Beta Was this translation helpful? Give feedback.
-
is there any tutorial for deploying on railway? |
Beta Was this translation helpful? Give feedback.
-
What if you already have a large database locally?? How can you get that onto fly.io? |
Beta Was this translation helpful? Give feedback.
-
This was requested several times in #498, #432, #328 and others.
Note 1: There will be an official Docker image when PocketBase reach a more stable release
Note 2: I didn't spend too much time exploring all Fly.io configurations so maybe there is a better/easier way to do it.
Note 3: Fly.io has a 60s timeout for idle connections, so you may get periodically errors in the console when using the realtime service. You can ignore them, since the SDK handles the reconnect automatically (#642).
1. Create the PocketBase Dockerfile:
2. Install Flyctl
Follow the installation instructions from https://fly.io/docs/hands-on/install-flyctl/.
Run
flyctl auth signup
to create a Fly.io account (email or GitHub).Run
flyctl auth login
to login.The above commands will open a browser window to authenticate with your Fly account.
If you see a screen saying to enter your billing details you can ignore it (as of now Fly has both free and paid regions; more on that see below).
3. Launch (aka. machine setup)
Navigate to the directory where the Dockerfile from 1) was created.
Run
flyctl launch --build-only
(optionally you can specify--dockerfile
if you are running from different directory).This will prompt you a question in the terminal like:
Type
y
to adjust the settings to the free allowance. This will open the following page:In the above page you need to change 2 mandatory things to enable the free plan:
*
).Click on the "Confirm Settings" button at the bottom and after this a
fly.toml
configuration file will be created in your working directory.4. Create and mount 1GB free persistent volume
Run
flyctl volumes create pb_data --size=1
.You may get a warning like:
Type
y
to confirm.And then it should prompt you to select a region - preferably choose the same region as in 3).
Once finished, open your
fly.toml
and add somewhere at the root level the followingmounts
config:Your final
fly.toml
should look something like this:5. Deploy
Run
flyctl deploy
and that's it!To access your PocketBase dashboard navigate to
https://YOUR_APP_NAME.fly.dev/_/
.To deploy new configuration/image changes, just run
flyctl deploy
again.Backup and downloading a copy of your
pb_data
Fly.io will even create a daily snapshot automatically for your volume (it will be kept for 5 days) - https://fly.io/docs/reference/volumes/#snapshots-and-restores.
To download a copy of your remote
pb_data
directory to your local machine, you could run the following commands in 2 separate terminals:Beta Was this translation helpful? Give feedback.
All reactions