Compare commits
No commits in common. "0.2-rc1" and "master" have entirely different histories.
33
DEPLOYING.md
33
DEPLOYING.md
|
@ -1,33 +0,0 @@
|
||||||
# Deploying a production instance
|
|
||||||
Hi fellow sysadmins!
|
|
||||||
First of all, I want to thank you for using my piece of software.
|
|
||||||
The instructions can be found below
|
|
||||||
|
|
||||||
## Deploying a basic instance
|
|
||||||
To deploy a basic instance for general public use, follow these simple steps:
|
|
||||||
1. Clone this repo
|
|
||||||
2. Copy `docker-compose.prod.yml` to `docker-compose.yml` and edit it to fit your environment
|
|
||||||
3. Now, there are a few config files that need to be edited by you: `.env`, `filed/.env` and `janitord/.env`. Each directory contains an `.env.example`, and the configuration is pretty straightforward. However, if you are lost check this out: [filed config](#filed-configuration), [janitord config](#janitord-configuration).
|
|
||||||
4. Configure fileD using `filed/config/filed.toml`. The example is in the same folder. Example contains a lot of self-documenting comments, so it should be pretty simple too.
|
|
||||||
5. Set `REDIS_PASS` to a secure long string. Not exactly required, but this is something you would want to do
|
|
||||||
6. Create and start containers with `docker-compose up -d`
|
|
||||||
7. Route your top level reverse proxy to the `caddy` service or to the port that you opened via the docker compose file.
|
|
||||||
|
|
||||||
## More extensive configuration
|
|
||||||
Well, generally, time-wise, it is not really a good idea to create a custom services configuration.
|
|
||||||
However, I will guide you through the basic minimal configuration.
|
|
||||||
|
|
||||||
Basically, the most minimal blek!File is a fileD service connected to a redis database.
|
|
||||||
I think that if you are clinically insance, you can set these up as a systemd services or a `screen`ed program.
|
|
||||||
|
|
||||||
However, its not really recommended to run this without janitorD as unused files will just clog up your filesystem.
|
|
||||||
The two requirements for janitorD are to have access to the fileD's usercontent directory and the Redis database.
|
|
||||||
The default docker configuration mounts `/opt/user_content` to the same volume for both fileD and janitorD.
|
|
||||||
|
|
||||||
## FileD configuration
|
|
||||||
Unless you are running in some kind of super customized docker compose environment, just copying the `.env.example` to `.env` should be enough to get it to run.
|
|
||||||
|
|
||||||
Don't forget to set the `REDIS_PASS` to the same value across all services
|
|
||||||
|
|
||||||
## JanitorD configuration
|
|
||||||
Same as [filed config](#filed-configuration), don't forget to set `REDIS_PASS` to a valid value
|
|
22
README.md
22
README.md
|
@ -1,3 +1,10 @@
|
||||||
|
| ⚠️ This is in a rather early stage of development and shouldn't be deployed |
|
||||||
|
| --------------------------------------------------------------------------- |
|
||||||
|
|
||||||
|
Even though this project is mature enough to be deployed in a public instance,
|
||||||
|
this is highly discouraged.
|
||||||
|
However, if you do this, be prepared for [DOS](https://en.wikipedia.org/wiki/Denial-of-service_attack) issues and API changes.
|
||||||
|
<br/>
|
||||||
|
|
||||||
<h1 align='center'>
|
<h1 align='center'>
|
||||||
<img src="./filed/static/android-chrome-192x192.png"/>
|
<img src="./filed/static/android-chrome-192x192.png"/>
|
||||||
|
@ -9,21 +16,6 @@ blek! File is a free service that would help you with file sharing.
|
||||||
|
|
||||||
The principle is very simple: you upload a file, then download it from another device. The file will be deleted after 1 download or 30 minutes.
|
The principle is very simple: you upload a file, then download it from another device. The file will be deleted after 1 download or 30 minutes.
|
||||||
|
|
||||||
## Public instances
|
|
||||||
List of official instances
|
|
||||||
|
|
||||||
| Name | Administrator | URL |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| 🌠 blek! File | b1ek <me@blek.codes> | [https://file.blek.codes](file.blek.codes) |
|
|
||||||
|
|
||||||
To add your instance in this list, fork and open a PR.
|
|
||||||
|
|
||||||
To qualify, your instance must be having:
|
|
||||||
1. Uploads without a password turned on
|
|
||||||
2. Have proper ToS
|
|
||||||
3. Come up with a unique name
|
|
||||||
4. Have a public administrator email
|
|
||||||
|
|
||||||
## Licensing
|
## Licensing
|
||||||
This software is released under GPL3 license, a copyleft license that protects users' freedom by ensuring that all future copies of this software are open source as well.
|
This software is released under GPL3 license, a copyleft license that protects users' freedom by ensuring that all future copies of this software are open source as well.
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ services:
|
||||||
networks:
|
networks:
|
||||||
bfile:
|
bfile:
|
||||||
volumes:
|
volumes:
|
||||||
- './.git:/opt/code/.git'
|
|
||||||
- './filed:/opt/code'
|
- './filed:/opt/code'
|
||||||
- './filed/config:/etc/filed'
|
- './filed/config:/etc/filed'
|
||||||
- '/opt/code/target'
|
- '/opt/code/target'
|
||||||
|
|
|
@ -2,8 +2,8 @@ version: '3.7'
|
||||||
services:
|
services:
|
||||||
filed:
|
filed:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: filed
|
||||||
dockerfile: filed/Dockerfile.prod
|
dockerfile: Dockerfile.prod
|
||||||
networks:
|
networks:
|
||||||
bfile:
|
bfile:
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
@ -358,7 +358,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filed"
|
name = "filed"
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"askama",
|
"askama",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "filed"
|
name = "filed"
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -2,17 +2,16 @@
|
||||||
FROM rust:alpine as builder
|
FROM rust:alpine as builder
|
||||||
|
|
||||||
WORKDIR /opt/build
|
WORKDIR /opt/build
|
||||||
COPY filed .
|
COPY . .
|
||||||
COPY ./.git ./.git
|
|
||||||
|
|
||||||
RUN apk add --no-cache git musl-dev upx nodejs yarn && \
|
RUN apk add --no-cache musl-dev upx nodejs yarn && \
|
||||||
yarn global add uglify-js@3.17.4
|
yarn global add uglify-js
|
||||||
|
|
||||||
RUN cargo b -r
|
RUN cargo b -r
|
||||||
RUN strip target/release/filed && upx --best target/release/filed
|
RUN strip target/release/filed && upx --best target/release/filed
|
||||||
|
|
||||||
# --- deploy ---
|
# --- deploy ---
|
||||||
FROM alpine:3.17
|
FROM busybox:musl
|
||||||
|
|
||||||
RUN mkdir /config
|
RUN mkdir /config
|
||||||
WORKDIR /config
|
WORKDIR /config
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
use std::{fs, path::PathBuf, ffi::OsStr, process::Command, error::Error};
|
use std::{fs, path::PathBuf, ffi::OsStr, process::Command};
|
||||||
|
|
||||||
use css_minify::optimizations::{Minifier, Level};
|
use css_minify::optimizations::{Minifier, Level};
|
||||||
|
|
||||||
|
@ -17,19 +17,6 @@ fn extfilter(valid: String, x: Option<&OsStr>) -> bool {
|
||||||
ext == valid
|
ext == valid
|
||||||
}
|
}
|
||||||
|
|
||||||
fn system(cmd: &str, args: &[&str]) -> Result<String, Box<dyn Error>> {
|
|
||||||
let out = Command::new(cmd)
|
|
||||||
.args(args)
|
|
||||||
.output()
|
|
||||||
?;
|
|
||||||
|
|
||||||
if out.stderr.len() != 0 {
|
|
||||||
panic!("Got this while running {cmd} with \"{}\": {}", args.join(" "), String::from_utf8(out.stderr).unwrap())
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(String::from_utf8(out.stdout)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed=static/assets");
|
println!("cargo:rerun-if-changed=static/assets");
|
||||||
|
@ -65,24 +52,11 @@ fn main() {
|
||||||
|
|
||||||
scripts.iter().for_each(|asset| {
|
scripts.iter().for_each(|asset| {
|
||||||
Command::new("uglifyjs")
|
Command::new("uglifyjs")
|
||||||
|
.arg("-c")
|
||||||
.arg(asset)
|
.arg(asset)
|
||||||
.arg("-o")
|
.arg("-o")
|
||||||
.arg(asset_path(asset))
|
.arg(asset_path(asset))
|
||||||
.arg("-c")
|
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
});
|
})
|
||||||
|
|
||||||
let commit = system("git", &["rev-parse", "HEAD"]).map_err(|x| x.to_string());
|
|
||||||
let branch = system("git", &["rev-parse", "--abbrev-ref", "HEAD"]).map_err(|x| x.to_string());
|
|
||||||
|
|
||||||
match commit {
|
|
||||||
Err(err) => panic!("Can't get commit: {}", err),
|
|
||||||
Ok(commit) => println!("cargo:rustc-env=COMMIT_HASH={commit}")
|
|
||||||
}
|
|
||||||
|
|
||||||
match branch {
|
|
||||||
Err(err) => panic!("Can't get commit: {}", err),
|
|
||||||
Ok(branch) => println!("cargo:rustc-env=COMMIT_BRANCH={branch}")
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -15,23 +15,6 @@ pub struct Redis {
|
||||||
pub prefix: String
|
pub prefix: String
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct VersionData {
|
|
||||||
pub commit: String,
|
|
||||||
pub short_commit: String,
|
|
||||||
pub branch: String
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for VersionData {
|
|
||||||
fn default() -> Self {
|
|
||||||
VersionData {
|
|
||||||
commit: env!("COMMIT_HASH").to_string(),
|
|
||||||
short_commit: env!("COMMIT_HASH").to_string().chars().take(6).collect(),
|
|
||||||
branch: env!("COMMIT_BRANCH").to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Env {
|
pub struct Env {
|
||||||
pub logging: bool,
|
pub logging: bool,
|
||||||
|
@ -41,8 +24,7 @@ pub struct Env {
|
||||||
pub filedir: String,
|
pub filedir: String,
|
||||||
pub instanceurl: String,
|
pub instanceurl: String,
|
||||||
pub uploadspath: String,
|
pub uploadspath: String,
|
||||||
pub confpath: String,
|
pub confpath: String
|
||||||
pub version: VersionData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_var<T: Into<String>, O: From<String>>(name: T) -> Result<O, String> {
|
fn get_var<T: Into<String>, O: From<String>>(name: T) -> Result<O, String> {
|
||||||
|
@ -158,8 +140,7 @@ pub fn loadenv() -> Result<Env, Box<dyn std::error::Error>> {
|
||||||
return Err(format!("CONF_FILE is {}, which is not a file!", spath).into())
|
return Err(format!("CONF_FILE is {}, which is not a file!", spath).into())
|
||||||
}
|
}
|
||||||
spath
|
spath
|
||||||
},
|
}
|
||||||
version: VersionData::default()
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
web - The part of filed that handles everything related to HTTP
|
web - The part of filed that handles everything related to HTTP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use std::env::current_dir;
|
||||||
|
|
||||||
use static_dir::static_dir;
|
use static_dir::static_dir;
|
||||||
use warp::{Filter, reply::Reply, reject::Rejection};
|
use warp::{Filter, reply::Reply, reject::Rejection};
|
||||||
|
|
||||||
|
@ -17,11 +19,15 @@ mod uploaded;
|
||||||
use state::SharedState;
|
use state::SharedState;
|
||||||
|
|
||||||
pub fn routes(state: SharedState) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
|
pub fn routes(state: SharedState) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
|
||||||
static_dir!("static")
|
let staticpath = current_dir().unwrap();
|
||||||
.or(pages::get_routes(state.clone()))
|
let staticpath = staticpath.to_str().unwrap().to_string() + "/static";
|
||||||
|
|
||||||
|
pages::get_routes(state.clone())
|
||||||
.or(forms::get_routes(state.clone()))
|
.or(forms::get_routes(state.clone()))
|
||||||
.or(api::get_routes(state.clone()))
|
.or(api::get_routes(state.clone()))
|
||||||
.or(uploaded::get_uploaded(state))
|
.or(uploaded::get_uploaded(state))
|
||||||
|
.or(static_dir!("static"))
|
||||||
|
.or(warp::fs::dir(staticpath.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -66,13 +66,6 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<small>Made with Rust and <3</small>
|
<small>Made with Rust and <3</small>
|
||||||
|
|
||||||
<small style="display:block">
|
|
||||||
Version
|
|
||||||
<a href="https://git.blek.codes/blek/bfile/commit/{{ env.version.commit }}" target="_blank">
|
|
||||||
{{ env!("CARGO_PKG_VERSION") }} ({{ env.version.branch -}}/{{- env.version.short_commit }})
|
|
||||||
</a>
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<ul style='margin:10px 0'>
|
<ul style='margin:10px 0'>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -10,7 +10,7 @@ RUN cargo b -r
|
||||||
RUN strip target/release/janitor && upx --best target/release/janitor
|
RUN strip target/release/janitor && upx --best target/release/janitor
|
||||||
|
|
||||||
# --- deploy ---
|
# --- deploy ---
|
||||||
FROM alpipne:3.17
|
FROM busybox:musl
|
||||||
|
|
||||||
RUN mkdir /config
|
RUN mkdir /config
|
||||||
WORKDIR /config
|
WORKDIR /config
|
||||||
|
|
Loading…
Reference in New Issue