Add containerfile and fix all issues

This commit is contained in:
Xander 2023-10-22 12:31:51 +02:00
parent ccee0f7ca6
commit 3ac0ecfec2
8 changed files with 76 additions and 31 deletions

29
Containerfile Normal file
View file

@ -0,0 +1,29 @@
FROM rust:latest
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
RUN chmod a+r /etc/apt/keyrings/docker.gpg
RUN echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update && apt-get install cmake npm docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
WORKDIR /pw
COPY . .
RUN cargo build --release
RUN cargo install wasm-pack
RUN wasm-pack build web/planetwars-rs --target web
WORKDIR /pw/web/pw-server
RUN npm install --force && npm run build
RUN sed "s/module.exports=y;//" /pw/web/pw-server/.svelte-kit/output/client/_app/chunks/PlayerLog-c14926a0.js -i
WORKDIR /pw/planetwars-server
ENTRYPOINT ["../target/release/planetwars-server", "npm --prefix /pw/web/pw-server run preview -- --host"]

7
bot.toml Normal file
View file

@ -0,0 +1,7 @@
# Comand to run when starting the bot.
# Argv style also supported: ["python", "simplebot.py"]
command = "python simplebot.py"
# Directory in which to run the command.
# It is recommended to use an absolute path here.
working_directory = "/home/planetwars/planetwars.dev/simplebot"

View file

@ -167,7 +167,7 @@ pub fn get_config() -> Result<GlobalConfig, ConfigError> {
async fn run_registry(config: Arc<GlobalConfig>, db_pool: DbPool) {
// TODO: put in config
let addr = SocketAddr::from(([127, 0, 0, 1], 9001));
let addr = SocketAddr::from(([0, 0, 0, 0], 9001));
axum::Server::bind(&addr)
.serve(
@ -193,7 +193,7 @@ pub async fn run_app() {
tokio::spawn(run_client_api(global_config.clone(), db_pool.clone()));
// TODO: put in config
let addr = SocketAddr::from(([127, 0, 0, 1], 9000));
let addr = SocketAddr::from(([0, 0, 0, 0], 9000));
let pw_api_service = create_pw_api(global_config, db_pool).into_make_service();
axum::Server::bind(&addr)

View file

@ -377,7 +377,7 @@ pub async fn run_client_api(runner_config: Arc<GlobalConfig>, pool: ConnectionPo
runner_config,
};
let addr = SocketAddr::from(([127, 0, 0, 1], 50051));
let addr = SocketAddr::from(([0, 0, 0, 0], 50051));
Server::builder()
.add_service(pb::client_api_service_server::ClientApiServiceServer::new(
server,

View file

@ -141,8 +141,9 @@ pub fn bot_version_to_botspec(
}
fn python_docker_bot_spec(config: &GlobalConfig, code_bundle_path: &str) -> Box<dyn BotSpec> {
let code_bundle_rel_path = PathBuf::from(&config.bots_directory).join(code_bundle_path);
let code_bundle_abs_path = std::fs::canonicalize(&code_bundle_rel_path).unwrap();
let code_bundle_abs_path = PathBuf::from("/home/planetwars/data/bots").join(code_bundle_path);
//let code_bundle_abs_path = std::fs::canonicalize(&code_bundle_rel_path).unwrap();
println!("{}",code_bundle_abs_path.display());
let code_bundle_path_str = code_bundle_abs_path.as_os_str().to_str().unwrap();
// TODO: it would be good to simplify this configuration

View file

@ -108,6 +108,10 @@ pub async fn list_recent_matches(
None => matches::list_public_matches(count, params.before, params.after, &mut conn),
};
match matches_result {
Ok(_) => println!("ok"),
Err(ref err) => println!("{}",err)
};
let mut matches = matches_result.expect("failed to get matches"); //.map_err(|_| StatusCode::BAD_REQUEST)?;
let mut has_next = false;

4
simplebot/Containerfile Normal file
View file

@ -0,0 +1,4 @@
FROM python:alpine
WORKDIR /app
COPY simplebot.py simplebot.py
CMD python simplebot.py

View file

@ -12,37 +12,37 @@
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"devDependencies": {
"@originjs/vite-plugin-commonjs": "^1.0.1",
"@originjs/vite-plugin-commonjs": "1.0.1",
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "^1.0.0-next.286",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.30",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^3.2.1",
"luxon": "^2.3.0",
"mdsvex": "^0.10.6",
"prettier": "^2.4.1",
"prettier-plugin-svelte": "^2.4.0",
"sass": "^1.49.7",
"svelte": "^3.52.0",
"svelte-check": "^2.2.6",
"svelte-preprocess": "^4.9.4",
"tslib": "^2.3.1",
"typescript": "^4.4.3",
"vite-plugin-iso-import": "^0.1.3"
"@sveltejs/kit": "1.0.0-next.286",
"@sveltejs/vite-plugin-svelte": "1.0.0-next.49",
"@typescript-eslint/eslint-plugin": "4.31.1",
"@typescript-eslint/parser": "4.31.1",
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-svelte3": "3.2.1",
"luxon": "2.3.0",
"mdsvex": "0.10.6",
"prettier": "2.4.1",
"prettier-plugin-svelte": "2.4.0",
"sass": "1.49.7",
"svelte": "3.52.0",
"svelte-check": "2.2.6",
"svelte-preprocess": "4.9.4",
"tslib": "2.3.1",
"typescript": "4.4.3",
"vite-plugin-iso-import": "0.1.3"
},
"dependencies": {
"@fortawesome/free-solid-svg-icons": "^6.2.0",
"@sveltejs/adapter-node": "^1.0.0-next.69",
"@types/luxon": "^2.0.9",
"ace-builds": "^1.4.14",
"dayjs": "^1.10.7",
"@fortawesome/free-solid-svg-icons": "6.2.0",
"@sveltejs/adapter-node": "1.0.0-next.69",
"@types/luxon": "2.0.9",
"ace-builds": "1.4.14",
"dayjs": "1.10.7",
"planetwars-rs": "file:../planetwars-rs/pkg",
"pw-visualizer": "file:../pw-visualizer",
"svelte-fa": "^3.0.3",
"svelte-select": "^5.0.0-beta.31"
"svelte-fa": "3.0.3",
"svelte-select": "5.0.0-beta.31"
},
"type": "module"
}