Hi,
To clarify. I’m not using Fly.io for now. I’m still working on making my app work with LiteFS on a docker container.
My base image is alpine
and this is my Dockerfile
# Fetch the LiteFS binary using a multi-stage build.
FROM flyio/litefs:0.2 AS litefs
# Build our Go application the handler to save data in DB
FROM golang:1.16-alpine AS builder
WORKDIR /af-litefs-poc
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY *.go ./
RUN apk add build-base
RUN go build -o main .
# af-litefs-poc listens on 8081 so we'll copy it. Health-checks are configured to listen on 8081 for now as well with
# localhost:8081/readiness
EXPOSE 8081
# Because our main process is LiteFS that runs our Handler go app as a sub process so the command to run our app -
# CMD ["/af-litefs-poc/main"]
# will be executed within the LiteFS process. Therefore the command will be in the etc/litefs.yml file under `exec`
# Our final Docker image stage starts here - LiteFS is the main process
FROM alpine
# Copy binaries from the previous build stages.
COPY --from=builder /af-litefs-poc /usr/local/bin/af-litefs-poc
COPY --from=litefs /usr/local/bin/litefs /usr/local/bin/litefs
# Copy our LiteFS configuration.
ADD etc/litefs.yml /etc/litefs.yml
# Setup our environment to include FUSE & SQLite.
RUN apk add bash curl fuse sqlite
# Ensure our mount & data directories exists before mounting with LiteFS.
RUN mkdir -p /data /mnt/data
ENTRYPOINT "litefs"
After I build the image if I try to run my container using the following command:
docker run -d -p 8081:8081 litefs_app
I get the following error:
E2022-12-13T13:06:44.997875016Z config file read from /etc/litefs.yml
]2022-12-13T13:06:45.002532068Z primary lease acquired, advertising as http://localhost:20202
p2022-12-13T13:06:45.003717968Z mount helper error: fusermount: fuse device not found, try 'modprobe fuse' first
k2022-12-13T13:06:45.003738443Z cannot init file system: cannot open file system: fusermount: exit status 1
A2022-12-13T13:06:45.003742501Z exiting primary, destroying lease
After some research (including here) I added --cap-add SYS_ADMIN --device /dev/fuse --privileged
to my docker run
command and the the container is up and working.
Is there a way to avoid those flags when working on docker container with LiteFS?
Thanks