Skip to content

Commit f94fdd0

Browse files
authored
Move config to data dir and add dockerfile (#72)
1 parent b0f4732 commit f94fdd0

5 files changed

Lines changed: 35 additions & 5 deletions

File tree

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# inspiration: https://dev.to/rogertorres/first-steps-with-docker-rust-30oi
2+
3+
FROM rust:1.89-bookworm AS build
4+
5+
# create an empty shell project
6+
RUN USER=root cargo new --bin rusteze
7+
WORKDIR /rusteze
8+
9+
# copy manifests
10+
COPY ./Cargo.lock ./Cargo.lock
11+
COPY ./Cargo.toml ./Cargo.toml
12+
13+
# cache dependencies
14+
RUN cargo build --release
15+
RUN rm -r ./src
16+
17+
# copy real source
18+
COPY ./src ./src
19+
20+
# build for release
21+
RUN rm ./target/release/rusteze*
22+
RUN find ./src/ -exec touch '{}' ';'
23+
RUN cargo build --release
24+
25+
# executing image
26+
FROM debian:bookworm-slim
27+
28+
COPY --from=build /rusteze/target/release/rusteze .
29+
30+
ENTRYPOINT ["./rusteze"]

src/channels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use serenity::{
1515
};
1616
use std::{collections::HashMap, fs::File, io, sync::Arc};
1717

18-
const COURSES: &str = "courses.json";
18+
const COURSES: &str = "data/courses.json";
1919
const DEPRECATED_CATEGORY: ChannelId = ChannelId::new(618553779192856577);
2020

2121
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq)]

src/commands/cesium.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const CESIUM_CATEGORY: ChannelId = ChannelId::new(418798551317872660);
3434
pub const CESIUM_ROLE: RoleId = RoleId::new(418842665061318676);
3535
const MODS_ROLE: RoleId = RoleId::new(618572138718298132);
3636
const MENTOR_ROLE: RoleId = RoleId::new(688760837980291120);
37-
const CHANNELS: &str = "cesium_channels.json";
37+
const CHANNELS: &str = "data/cesium_channels.json";
3838

3939
#[check]
4040
#[name = "is_mod_or_cesium"]

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::util::SendSyncError as Error;
22
use serde::{Deserialize, Serialize};
3-
use serde_with::{serde_as, DisplayFromStr};
3+
use serde_with::{DisplayFromStr, serde_as};
44
use serenity::{
55
model::id::{ChannelId, RoleId},
66
prelude::{RwLock, TypeMapKey},
@@ -29,7 +29,7 @@ pub struct Config {
2929
mute_role: Option<RoleId>,
3030
}
3131

32-
const CONFIG: &str = "config.json";
32+
const CONFIG: &str = "data/config.json";
3333

3434
impl Config {
3535
fn serialize(&self) -> Result<(), Error> {

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::{fs, sync::Arc};
1212

1313
#[tokio::main]
1414
async fn main() {
15-
let token = match fs::read_to_string("auth") {
15+
let token = match fs::read_to_string("data/auth") {
1616
Ok(token) => token,
1717
Err(e) => {
1818
log!("Could not open auth file");

0 commit comments

Comments
 (0)