R
Railway3mo ago
Mirsa

Pocketbase persistent data

I deployed a custom version of pocketbase, and i created a volume at /pb_data but i have an issue with the persistence isn't working, i guess it's a problem with the path/directory.
# Use the official Go image to build the PocketBase binary
FROM golang:1.21-alpine AS builder

# Set the working directory
WORKDIR /app

# Copy go mod and sum files
COPY go.mod go.sum ./

# Download all dependencies
RUN go mod download

# Copy the source code into the container
COPY . .

# Build the PocketBase application
RUN CGO_ENABLED=0 GOOS=linux go build -o pocketbase .

# Start a new stage from scratch
FROM alpine:latest

# Install necessary packages
RUN apk add --no-cache ca-certificates

# Set the working directory
WORKDIR /pb

ENV PORT=8080

# Expose port 8080
EXPOSE 8080

# Copy the binary from the builder stage
COPY --from=builder /app/pocketbase /usr/local/bin/pocketbase

# Command to run PocketBase
CMD ["/usr/local/bin/pocketbase", "serve", "--http=0.0.0.0:8080", "--dir=/pb_data", "--publicDir=/pb_public"]
# Use the official Go image to build the PocketBase binary
FROM golang:1.21-alpine AS builder

# Set the working directory
WORKDIR /app

# Copy go mod and sum files
COPY go.mod go.sum ./

# Download all dependencies
RUN go mod download

# Copy the source code into the container
COPY . .

# Build the PocketBase application
RUN CGO_ENABLED=0 GOOS=linux go build -o pocketbase .

# Start a new stage from scratch
FROM alpine:latest

# Install necessary packages
RUN apk add --no-cache ca-certificates

# Set the working directory
WORKDIR /pb

ENV PORT=8080

# Expose port 8080
EXPOSE 8080

# Copy the binary from the builder stage
COPY --from=builder /app/pocketbase /usr/local/bin/pocketbase

# Command to run PocketBase
CMD ["/usr/local/bin/pocketbase", "serve", "--http=0.0.0.0:8080", "--dir=/pb_data", "--publicDir=/pb_public"]
33 Replies
Percy
Percy3mo ago
Project ID: 4e78d088-677d-4ecb-ba7a-8eb3bd3bd174
Mirsa
MirsaOP3mo ago
4e78d088-677d-4ecb-ba7a-8eb3bd3bd174
Brody
Brody3mo ago
what does --dir represent in this case?
Mirsa
MirsaOP3mo ago
i think it represents the directory where PocketBase will store its data
Brody
Brody3mo ago
have you tried /pb/pb_data ?
Mirsa
MirsaOP3mo ago
i did not
Mirsa
MirsaOP3mo ago
No description
Brody
Brody3mo ago
switch to the v2 runtime and then use target ports on your domain
Mirsa
MirsaOP3mo ago
"then use target ports on your domain" what you mean
Brody
Brody3mo ago
instead of me explaining, remove and re-add your domain after switching to the v2 runtime and you will see what i mean
Mirsa
MirsaOP3mo ago
same
Brody
Brody3mo ago
from your logs -
Error: unknown flag: --publicDir
Error: unknown flag: --publicDir
Mirsa
MirsaOP3mo ago
since it's the default folder i'll remove that should i do the same for --dir/pb_data ?
Brody
Brody3mo ago
the template doesnt set a dir, so maybe omit that too
Mirsa
MirsaOP3mo ago
meh.. 0.056 go: go.mod requires go >= 1.22 (running go 1.21.13; GOTOOLCHAIN=local) I need go minimal 1.22 how to update this in docker image ?
Brody
Brody3mo ago
line 2 of your dockerfile
Mirsa
MirsaOP3mo ago
ok now maybe the right path to the volume is /pb_data
Brody
Brody3mo ago
I would first leave it at /pb/pb_data
Mirsa
MirsaOP3mo ago
ok i redeploy to test it ok this path isn't working
Brody
Brody3mo ago
what about pocket base have you changed anyway?
Mirsa
MirsaOP3mo ago
Okey with pb/pb_data did - i updated it deployed - backup my data - tested the data persistence with a redeploy But everything got erased
Brody
Brody3mo ago
can you try the pocket base template please
Mirsa
MirsaOP3mo ago
the pocketbase template works fine but i have a custom main.go pocketbase code
Brody
Brody3mo ago
you have no issues with data persistence using the template, correct?
Mirsa
MirsaOP3mo ago
yep
Brody
Brody3mo ago
okay then it's something you are misconfiguring please send the GitHub repo for your pocketbase
Mirsa
MirsaOP3mo ago
Im doing the test again with volume on /pb_data.
Brody
Brody3mo ago
going forward let's leave the volume mounted to /pb/pb_data as that's what the template has the volume mounted to
Mirsa
MirsaOP3mo ago
F.... it's same... both are not working
Brody
Brody3mo ago
^
Mirsa
MirsaOP3mo ago
GitHub
GitHub - asmirbe/pocketbase
Contribute to asmirbe/pocketbase development by creating an account on GitHub.
Mirsa
MirsaOP3mo ago
Can't understand what is causing the issue....
Brody
Brody3mo ago
then I'm unsure, all I have for you right now is that something you have done is misconfigured.
Want results from more Discord servers?
Add your server