forked from obviyus/HamVerBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docker): create Dockerfile to deploy to fly.io
- Loading branch information
Showing
4 changed files
with
76 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
**/debug | ||
**/target | ||
**/vendor | ||
|
||
# These are backup files generated by rustfmt | ||
**/**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
**/*.pdb | ||
|
||
# IDE | ||
**/.idea | ||
**/.vscode | ||
|
||
# Configs | ||
fly.toml |
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,38 @@ | ||
FROM rust:latest as builder | ||
|
||
# Make a fake Rust app to keep a cached layer of compiled crates | ||
RUN USER=root cargo new app | ||
WORKDIR /usr/src/app | ||
COPY Cargo.toml Cargo.lock ./ | ||
|
||
# Needs at least a main.rs file with a main function | ||
RUN mkdir src && echo "fn main(){}" > src/main.rs | ||
|
||
# Will build all dependent crates in release mode | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=/usr/src/app/target \ | ||
cargo build --release | ||
|
||
# Copy the rest | ||
COPY . . | ||
|
||
# Build (install) the actual binaries | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=/usr/src/app/target \ | ||
cargo install --path . | ||
|
||
# Runtime image | ||
FROM debian:bullseye-slim | ||
|
||
# Run as "app" user | ||
RUN useradd -ms /bin/bash app | ||
|
||
USER app | ||
WORKDIR /app | ||
|
||
# Get compiled binaries from builder's cargo install directory | ||
COPY --from=builder /usr/local/cargo/bin/HamVerBot /app/HamVerBot | ||
|
||
# Copy the config and DB files (workaround!) | ||
COPY config.toml /app/config.toml | ||
COPY db/HamVerBot.db /app/db/HamVerBot.db |
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,18 @@ | ||
# fly.toml file generated for hamverbot on 2023-02-27T17:38:35+05:30 | ||
|
||
app = "hamverbot" | ||
kill_signal = "SIGINT" | ||
kill_timeout = 5 | ||
processes = [] | ||
|
||
[env] | ||
|
||
[experimental] | ||
auto_rollback = true | ||
cmd = "./HamVerBot" | ||
|
||
[[mounts]] | ||
source = "hamverbot_data" | ||
destination = "/app/db" | ||
|
||
[[services]] |