Setup Docker container

This commit is contained in:
toast 2023-12-08 21:19:17 +11:00
parent c5eb818a12
commit 2b2dcb1b55
4 changed files with 28 additions and 0 deletions

5
.dockerignore Normal file
View File

@ -0,0 +1,5 @@
.vscode
target
.env
.gitignore
renovate.json

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM rust:1.74-alpine3.18 AS compiler
ENV RUSTFLAGS="-C target-feature=-crt-static"
RUN apk add --no-cache openssl-dev musl-dev
WORKDIR /usr/src/rustbot
RUN cargo build || true
COPY . .
RUN cargo fetch && cargo build -r
FROM alpine:3.19
RUN apk add --no-cache openssl-dev libgcc
WORKDIR /rustbot
COPY --from=compiler /usr/src/rustbot/target/release/rustbot .
CMD [ "./rustbot" ]

9
docker-compose.yml Normal file
View File

@ -0,0 +1,9 @@
version: '3.8'
services:
bot:
container_name: Rustbot
image: 'git.toast-server.net/toast/rustbot:main'
build: .
env_file:
- .env
restart: unless-stopped

View File

@ -33,6 +33,7 @@ pub async fn eval(
// Compile // Compile
let compiled_path = dir.path().join("temp"); let compiled_path = dir.path().join("temp");
println!("Compiling {} -> {}", file_path.display(), compiled_path.display());
let output = Command::new("rustc").arg(&file_path).arg("-o").arg(&compiled_path).output()?; let output = Command::new("rustc").arg(&file_path).arg("-o").arg(&compiled_path).output()?;
if !output.status.success() { if !output.status.success() {