Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker stagging #7

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

dist

# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage

# next.js
.next/
out/
build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# turbo
.turbo

# cargo

target/
web/
apps/
dash/
# Env
.env
.env.*
# Images
images/*

# Idea

.idea/*
49 changes: 27 additions & 22 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
{
"editor.defaultFormatter": "dprint",
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[toml]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[javascript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[typescript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[rust]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[markdown]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[json]": {
"editor.defaultFormatter": "dprint.dprint"
}
"editor.defaultFormatter": "dprint",
"deno.path": "/home/tricked/.deno/bin/deno",
"deno.enablePaths": ["embed-service", "init.ts"],
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[toml]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[javascript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[rust]": {
"editor.defaultFormatter": "matklad.rust-analyzer"
},
"[markdown]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[dockercompose]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ members = [
"desktop",
]

[profile.release]
[profile.production]
inherits="release"
codegen-units = 1
incremental = true
lto = true
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ekidd/rust-musl-builder as builder

WORKDIR /home/rust/

COPY . .
RUN sudo apt update -yq
RUN sudo apt-get install -yq python3
RUN cargo build --release --bin ascella

ENTRYPOINT ["./target/x86_64-unknown-linux-musl/release/ascella"]

FROM scratch
WORKDIR /home/rust/
COPY --from=builder /home/rust/target/x86_64-unknown-linux-musl/release/ascella .
ENTRYPOINT ["./ascella"]
54 changes: 1 addition & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1 @@
# Ascella Monorepo

this repo includes the various projects needed to run ascella

---
### Ascella - Backend

Discord: https://discord.gg/mY8zTARu4g

### Stack

- storage - localstorage ( s3 expensive smfh )
- database - postgresql using tokio postgres
- http - actix-web
- bot - twilight

### Selfhosting

There's no support for self hosting

### Development

You will need to create a .env file with the following entries.

```ini
# Postgresql database
DATABASE_URL=
DISCORD_TOKEN=
APPLICATION_ID=
WEBHOOK=
```

#### Faster Development start

```sh
cargo {run,build} --profile dev
```

#### Contributing

Check the issues tab to find issues that need to be resolved

## Formatting

for formatting we use [dprint](https://dprint.dev/install/) for formatting files `npm i dprint -g`

### Copyright

please contact me via discord (tricked#3777) before using any of the code i would greatly appreciate this.

### Donating

You can help keep ascella running by supporting me on [github sponsers](https://github.com/sponsors/Tricked-dev/)
# Ascella the full stack image uploader!
79 changes: 44 additions & 35 deletions bot/src/commands/profile.rs
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@
use super::super::prelude::*;

pub fn command() -> Command {
CommandBuilder::new("profile".into(), "View your profile.".into(), CommandType::ChatInput).build()
CommandBuilder::new(
"profile".into(),
"View your profile.".into(),
CommandType::ChatInput,
)
.build()
}

#[allow(clippy::or_fun_call)]

pub async fn execute(client: &Client, cmd: &ApplicationCommand, user: Users) -> Result<()> {
let images = get_user_image_count::exec(user.id).await?;
let images = get_user_image_count::exec(user.id).await?;

let message = format!(
"dashboard: https://dash.ascella.host\nid: `{id}`\nname: `{name}`\ndiscord_id: `{discord}`\npassword: `{pass}`\nautodelete images: `{auto}`\n\ndomain: `{domain}`\nimages: `{images}`\n\ndownload config [here](https://ascella.wtf/v2/ascella/config?id={id}&key={pass})\n```json\n{config}\n```",
id = user.id,
name = user.name,
discord = user.discord_id,
pass = user.key,
domain = user.domain,
auto = user.autodelete.map(|x| { x.to_string() }).unwrap_or("Images wont get deleted automatically".to_owned()),
images = images,
config = serde_json::to_string_pretty(&create_config(user.id, &user.key)).unwrap()
);
let message = format!(
"dashboard: https://dash.ascella.host\nid: `{id}`\nname: `{name}`\ndiscord_id: `{discord}`\npassword: `{pass}`\nautodelete images: `{auto}`\n\ndomain: `{domain}`\nimages: `{images}`\n\ndownload config [here]({backend_url}/v2/ascella/config?id={id}&key={pass})\n```json\n{config}\n```",
backend_url = env::var("BACKEND_URL").unwrap_or("https://ascella.host".to_owned()),
id = user.id,
name = user.name,
discord = user.discord_id,
pass = user.key,
domain = user.domain,
auto = user.autodelete.map(|x| { x.to_string() }).unwrap_or("Images wont get deleted automatically".to_owned()),
images = images,
config = serde_json::to_string_pretty(&create_config(user.id, &user.key)).unwrap()
);

let embed = create_embed().title("User profile").description(message).build()?;
let embed = create_embed()
.title("User profile")
.description(message)
.build()?;

client
.interaction_callback(
cmd.id,
&cmd.token,
&ChannelMessageWithSource(CallbackData {
allowed_mentions: Some(AllowedMentions {
parse: vec![],
users: vec![],
roles: vec![],
replied_user: true,
}),
components: None,
content: None,
embeds: Some(vec![embed]),
flags: Some(MessageFlags::EPHEMERAL),
tts: Some(false),
}),
)
.exec()
.await?;
client
.interaction_callback(
cmd.id,
&cmd.token,
&ChannelMessageWithSource(CallbackData {
allowed_mentions: Some(AllowedMentions {
parse: vec![],
users: vec![],
roles: vec![],
replied_user: true,
}),
components: None,
content: None,
embeds: Some(vec![embed]),
flags: Some(MessageFlags::EPHEMERAL),
tts: Some(false),
}),
)
.exec()
.await?;

Ok(())
Ok(())
}
Loading