• Home
  • About
    • lahuman photo

      lahuman

      열심히 사는 아저씨

    • Learn More
    • Facebook
    • LinkedIn
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

Pocketbase

22 Sep 2023

Reading time ~2 minutes

간단하게 Pocketbase를 fly.io에 올리는 방법을 설명합니다.

fly.io 설치 및 가입

1. 설치

다음 명령어로 쉽게 설치가 가능합니다.

# Windows:
$ iwr https://fly.io/install.ps1 -useb | iex
# Linux
$ curl -L https://fly.io/install.sh | sh
# Mac
$ brew install flyctl
# or
$ curl -L https://fly.io/install.sh | sh

2. 가입

웹 브라우저가 뜨고 신규 가입을 진행합니다.

$ flyctl auth signup

3. 로그인

가입 정보로 로그인 처리

$ flyctl auth login

docker 파일 생성

fly.io 에서 실행될 dockerfile을 생성합니다.

1. 작업 디렉터리 생성

# 작업 디렉터리 생성
$ mkdir project
$ cd project

2. docker 파일 생성

2023.09.26 기준 0.18.8이 최신 버전입니다.


FROM alpine:latest

ARG PB_VERSION=0.18.8

RUN apk add --no-cache \
    unzip \
    ca-certificates \
    openssh

# download and unzip PocketBase
ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip
RUN unzip /tmp/pb.zip -d /pb/

EXPOSE 8080

# start PocketBase
CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8080"]

3. fly 앱 생성

$ fly launch
Creating app in /Users/k/project
Scanning source code
Detected a Dockerfile app
? Choose an app name (leave blank to generate one): you2
automatically selected personal organization: Daniel
Some regions require a paid plan (bom, fra, maa).
See https://fly.io/plans to set up a plan.

? Choose a region for deployment: Tokyo, Japan (nrt)
App will use 'nrt' region as primary

Created app 'you2' in organization 'personal'
Admin URL: https://fly.io/apps/you2
Hostname: you2.fly.dev
? Would you like to set up a Postgresql database now? No
? Would you like to set up an Upstash Redis database now? No
Wrote config file fly.toml
? Would you like to deploy now? No # fly.toml 파일만 생성하고, 실제 deploy 하지 않는다.
Validating /Users/k/DEV/pocketBase/project/fly.toml
Platform: machines
✓ Configuration is valid
Your app is ready! Deploy with `flyctl deploy`

이후 생성된 fly.toml 파일에서 자동 정지 부분을 false로 수정합니다.

app = "you2"
primary_region = "nrt"

[build]
  PB_VERSION="0.18.8"

# mounts 추가
[mounts]
  destination = "/pb/pb_data"
  source = "pb_data"

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = false
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]
  # 추가
  [http_service.concurrency]
    type = "requests"
    soft_limit = 500
    hard_limit = 550

4. fly 배포

먼저 디스크를 생성 합니다.

 $ fly volumes create pb_data --size=1
 Warning! Individual volumes are pinned to individual hosts. You should create two or more volumes per application. You will have downtime if you only create one. Learn more at https://fly.io/docs/reference/volumes/
? Do you still want to use the volumes feature? Yes
Some regions require a paid plan (bom, fra, maa).
See https://fly.io/plans to set up a plan.

? Select region: Tokyo, Japan (nrt)
        ID: vol_dfdfaefedfzz
      Name: pb_data
       App: you2
    Region: nrt
      Zone: fe01
   Size GB: 1
 Encrypted: true
Created at: 22 Sep 23 02:31 UTC

이후 배포 합니다.

$ fly deploy

이후 다음 주소로 접근하면 접근이 됩니다.

https://{앱명}.fly.dev/

관리자 화면 접근

가장 먼저 다음의 관리자 화면에서 비밀번호를 설정하세요!

https://{앱명}.fly.dev/_

이후 활용 하면 되니다.

참고자료

  • PocketBase
  • Build and deploy a Pocketbase project with Docker and Fly.io
  • PocketBase 활용법 1탄. 나만의 pocketbase 서버 만들기 in Fly.io


pocketbaseopensource Share Tweet +1