-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
141 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
*.beam | ||
*.ez | ||
*.sqlite* | ||
.env | ||
.github | ||
.gitignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
FROM ghcr.io/gleam-lang/gleam:v0.31.0-rc1-erlang-alpine | ||
|
||
# Add LiteFS binary, to replicate the SQLite database. | ||
COPY --from=flyio/litefs:0.5 /usr/local/bin/litefs /usr/local/bin/litefs | ||
|
||
# Add project code | ||
COPY . /build/ | ||
|
||
# Compile the Gleam application | ||
RUN cd /build \ | ||
&& apk add fuse3 ca-certificates sqlite gcc build-base \ | ||
&& gleam export erlang-shipment \ | ||
&& mv build/erlang-shipment /app \ | ||
&& rm -r /build \ | ||
&& apk del gcc build-base \ | ||
&& addgroup -S packages \ | ||
&& adduser -S packages -G packages \ | ||
&& chown -R packages /app | ||
&& apk del gcc build-base | ||
|
||
COPY litefs.yml /etc/litefs.yml | ||
|
||
# Run the application | ||
USER packages | ||
WORKDIR /app | ||
ENTRYPOINT ["/app/entrypoint.sh"] | ||
CMD ["run", "server"] | ||
ENTRYPOINT litefs mount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# The fuse section describes settings for the FUSE file system. This file system | ||
# is used as a thin layer between the SQLite client in your application and the | ||
# storage on disk. It intercepts disk writes to determine transaction boundaries | ||
# so that those transactions can be saved and shipped to replicas. | ||
fuse: | ||
dir: "/litefs" | ||
|
||
# The data section describes settings for the internal LiteFS storage. We'll | ||
# mount a volume to the data directory so it can be persisted across restarts. | ||
# However, this data should not be accessed directly by the user application. | ||
data: | ||
dir: "/var/lib/litefs" | ||
|
||
# This flag ensure that LiteFS continues to run if there is an issue on starup. | ||
# It makes it easy to ssh in and debug any issues you might be having rather | ||
# than continually restarting on initialization failure. | ||
exit-on-error: false | ||
|
||
# This section defines settings for the option HTTP proxy. | ||
# This proxy can handle primary forwarding & replica consistency | ||
# for applications that use a single SQLite database. | ||
proxy: | ||
addr: ":3001" | ||
target: "localhost:3000" | ||
db: "packages.sqlite" | ||
passthrough: | ||
- "*.css" | ||
- "*.js" | ||
|
||
# This section defines a list of commands to run after LiteFS has connected | ||
# and sync'd with the cluster. You can run multiple commands but LiteFS expects | ||
# the last command to be long-running (e.g. an application server). When the | ||
# last command exits, LiteFS is shut down. | ||
exec: | ||
- cmd: "/app/entrypoint.sh run server" | ||
|
||
# The lease section specifies how the cluster will be managed. We're using the | ||
# "consul" lease type so that our application can dynamically change the primary. | ||
# | ||
# These environment variables will be available in your Fly.io application. | ||
lease: | ||
type: "consul" | ||
advertise-url: "http://${HOSTNAME}.vm.${FLY_APP_NAME}.internal:20202" | ||
candidate: ${FLY_REGION == PRIMARY_REGION} | ||
promote: true | ||
|
||
consul: | ||
url: "${FLY_CONSUL_URL}" | ||
key: "litefs/${FLY_APP_NAME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters