Skip to content

Commit dad2fa5

Browse files
vsilentvsilentdiaevdrobotizeit
authored
Actix impl tpl vsilent#11 (vsilent#12)
* Testing (vsilent#9) * upload artifacts * upload artifacts * syntax fix * try another approach * list files Co-authored-by: vsilent <jabberroid@gmail.com> * Update README.md * Add editorconfig. Append gitignore fot emacs * editorconfig * make fake admin for tests * remove extra code, keep minimal Co-authored-by: vsilent <jabberroid@gmail.com> Co-authored-by: Evgeny Duzhakov <diaevd@gmail.com> Co-authored-by: Vasili Pascal <vasili.pascal@gmail.com>
1 parent b1ad43c commit dad2fa5

32 files changed

+1062
-63
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
indent_style = space
10+
11+
[*.rs]
12+
indent_size = 4
13+
14+
[*.toml]
15+
indent_size = -1

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Created by https://www.gitignore.io/api/rust,code
22
# Edit at https://www.gitignore.io/?templates=rust,code
33

4+
# emacs
5+
*~
6+
\#*\#
7+
.\#*
8+
.emacs.desktop
9+
410
### Code ###
511
.vscode/*
612
!.vscode/settings.json
@@ -26,4 +32,5 @@ Cargo.lock
2632

2733
# End of https://www.gitignore.io/api/rust,code
2834

29-
.idea
35+
.idea
36+
*.db

Cargo.toml

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,59 @@ authors = ["Vasili Pascal <info@try.direct>"]
55
edition = "2018"
66

77
#[package.metadata.docs.rs]
8-
#features = ["openssl", "rustls", "compress", "secure-cookies"]
9-
#
10-
#[dependencies]
11-
#actix-web = { version = "3.0.0-alpha.2", features=["rustls"] }
12-
#actix-rt = "1.1.1"
13-
#actix-service = "1.0.6"
14-
#actix-cors = "0.3.0"
15-
#actix-http = "2.1.0"
16-
#actix = "0.10"
17-
#log = "0.4.11"
18-
#env_logger = "0.7.1"
19-
#serde = "1.0.116"
20-
#serde_derive = "1.0.116"
21-
#serde_json = "1.0.57"
22-
#dotenv = "0.15.0"
23-
#futures = "0.3.5"
24-
#failure = "0.1.8"
25-
#derive_more = "0.99.10"
26-
#jsonwebtoken = "7.2.0"
27-
#bcrypt = "0.8.2"
28-
#actix-tls = "2.0.0"
29-
#awc = { version = "2.0.0", default-features = false }
30-
#open-ssl = { package = "openssl", version = "0.10", optional = true }
31-
#rust-tls = { package = "rustls", version = "0.18.0", optional = true }
32-
#
33-
#[features]
34-
## openssl
35-
#openssl = ["actix-tls/openssl", "awc/openssl", "open-ssl"]
36-
## rustls
37-
#rustls = ["actix-tls/rustls", "awc/rustls", "rust-tls"]
38-
#default = ["compress"]
39-
#
40-
## content-encoding support
41-
#compress = ["actix-http/compress", "awc/compress"]
42-
#
43-
## sessions feature
44-
#secure-cookies = ["actix-http/secure-cookies"]
45-
#
46-
#[dependencies.chrono]
47-
#version = "0.4.15"
48-
#features = ["serde"]
8+
features = ["openssl", "rustls", "compress", "secure-cookies"]
9+
10+
[dependencies]
11+
actix-web = { version = "3.0.0-beta.3", features=["rustls"] }
12+
actix-rt = "2.1.0"
13+
actix-service = "1.0.6"
14+
actix-cors = "0.3.0"
15+
actix-http = "2.1.0"
16+
actix = "0.10"
17+
log = "0.4.11"
18+
env_logger = "0.7.1"
19+
serde = "1.0.116"
20+
bigdecimal = "0.0.14"
21+
diesel_migrations = "1.4.0"
22+
serde_derive = "1.0.116"
23+
serde_json = "1.0.59"
24+
dotenv = "0.15.0"
25+
futures = "0.3.5"
26+
failure = "0.1.8"
27+
derive_more = "0.99.10"
28+
jsonwebtoken = "7.2.0"
29+
bcrypt = "0.8.2"
30+
actix-tls = "2.0.0"
31+
awc = { version = "2.0.0", default-features = false }
32+
open-ssl = { package = "openssl", version = "0.10", optional = true }
33+
rust-tls = { package = "rustls", version = "0.18.0", optional = true }
34+
35+
[features]
36+
# openssl
37+
openssl = ["actix-tls/openssl", "awc/openssl", "open-ssl"]
38+
# rustls
39+
rustls = ["actix-tls/rustls", "awc/rustls", "rust-tls"]
40+
# content-encoding support
41+
compress = ["actix-http/compress", "awc/compress"]
42+
# sessions feature
43+
secure-cookies = ["actix-http/secure-cookies"]
44+
45+
default = ["compress"]
46+
47+
48+
[dependencies.chrono]
49+
version = "0.4.15"
50+
features = ["serde"]
51+
52+
[dependencies.uuid]
53+
version = "0.8.1"
54+
features = ["v4"]
55+
56+
[dependencies.diesel]
57+
version = "1.4.6"
58+
features = ["sqlite", "r2d2", "chrono", "numeric"]
59+
60+
[dev-dependencies.diesel]
61+
version = "1.4.6"
62+
features = ["r2d2", "chrono"]
63+

README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
![CI/CD](https://github.com/vsilent/stackdog/actions/workflows/docker.yml/badge.svg)
2+
![Security](https://github.com/vsilent/stackdog/actions/workflows/codacy-analysis.yml/badge.svg)
13
[![Crates.io](https://img.shields.io/crates/v/stackdog.svg)](https://crates.io/crates/stackdog)
24
[![Docs.rs](https://docs.rs/stackdog/badge.svg)](https://docs.rs/stackdog)
3-
[![Coverage Status](https://coveralls.io/repos/github/vsilent/stackdog/badge.svg?branch=master)](https://coveralls.io/github/vsilent/stackdog?branch=master)
4-
[![Build Status](https://travis-ci.com/vsilent/stackdog.svg?branch=master)](https://travis-ci.com/trydirect/stackdog)
55
![Docker Stars](https://img.shields.io/docker/stars/trydirect/stackdog.svg)
66
![Docker Pulls](https://img.shields.io/docker/pulls/trydirect/stackdog.svg)
77
[![Gitter chat](https://badges.gitter.im/stackdog/community.png)](https://gitter.im/stackdog/community)
@@ -21,7 +21,7 @@
2121

2222
## Table of contents
2323
- [Quick start](#quick-start)
24-
- [Request a feature](https://github.com/vsilent/stackdog/issues/new)
24+
- [Request a feature](https://github.com/vsilent/stackdog/issues/new)
2525
- [Documentation](#documentation)
2626
- [Contributing](#contributing)
2727
- [Versioning](#versioning)
@@ -38,12 +38,22 @@ This project is at early stage of development, see development [ROADMAP.md](ROAD
3838

3939
```
4040
cp .env.sample .env
41+
head -c16 /dev/urandom > src/secret.key
4142
docker-compose up
4243
```
4344

45+
### Setup diesel cli for sqlite, run migrations
46+
```aidl
47+
48+
cargo install diesel_cli --no-default-features --features sqlite
49+
diesel setup
50+
diesel migration run
51+
52+
```
53+
4454
### Documentation
45-
Stackdogs's documentation, included into this repo, is built with Jekyll and
46-
publicly hosted on GitHub Pages at https://stackdog.io
55+
Stackdogs's documentation, included into this repo, is built with Jekyll and
56+
publicly hosted on GitHub Pages at https://stackdog.io
4757

4858
### Contributing
4959
See [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -71,9 +81,9 @@ Get updates on Bootstrap's development and chat with the project maintainers and
7181
- <https://twitter.com/nydevel>
7282

7383
### Sponsors
74-
Support this project by becoming a sponsor.
84+
Support this project by becoming a sponsor.
7585

76-
Your logo will show up in this README with a link to your website.
86+
Your logo will show up in this README with a link to your website.
7787

7888
[Become a sponsor!](https://opencollective.com/stackdog#sponsor)
7989

@@ -84,7 +94,7 @@ This project exists thanks to all the people who contribute.
8494
Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/stackdog#backer)
8595
<a href="https://opencollective.com/stackdog#backers" target="_blank"><img src="https://opencollective.com/stackdog/backers.svg?width=890" /></a>
8696

87-
### Inspired by
97+
### Inspired by
8898

8999
- [Portainer](https://github.com/portainer/portainer) - A lightweight management UI for managing your Docker hosts or Docker Swarm clusters by [@portainer](https://github.com/portainer)
90100
- [Seagull](https://github.com/tobegit3hub/seagull) - Friendly Web UI to monitor docker daemon. by [@tobegit3hub](https://github.com/tobegit3hub)
@@ -93,10 +103,10 @@ Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/
93103
- [Yacht](https://github.com/SelfhostedPro/Yacht) :construction: - A Web UI for docker that focuses on templates and ease of use in order to make deployments as easy as possible. By [@SelfhostedPro](https://github.com/SelfhostedPro)
94104

95105
### Why another container management tool ?
96-
- Written in Rust
97-
- Better security
106+
- Written in Rust
107+
- Better security
98108
- Better performance
99109
- Modular design
100110

101111
## License
102-
[MIT](LICENSE-MIT)
112+
[MIT](LICENSE-MIT)

diesel.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# For documentation on how to configure this file,
2+
# see diesel.rs/guides/configuring-diesel-cli
3+
4+
[print_schema]
5+
file = "src/schema.rs"

docker-compose.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
version: '3'
2-
2+
volumes:
3+
db:
4+
driver: local
35
services:
46
stackdog:
57
container_name: backend
6-
image: trydirect/stackdog:latest
7-
# build:
8-
# context: .
9-
# dockerfile: docker/local/Dockerfile
8+
# image: trydirect/stackdog:latest
9+
build:
10+
context: .
11+
dockerfile: docker/local/Dockerfile
1012
entrypoint: [ 'bash', '-c', 'sleep infinity' ]
1113
# restart: always
1214
ports:
1315
- "5000:5000"
1416
env_file: .env
17+
volumes:
18+
- db:/app/db
19+

docker/local/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# build stage
22
FROM rust:slim as build
33

4-
# install libpq and create new empty binary project
4+
# install sqlite3 and create new empty binary project
55
RUN apt-get update; \
6-
apt-get install --no-install-recommends -y libpq-dev; \
6+
apt-get install --no-install-recommends -y sqlite3 libsqlite3-dev; \
77
rm -rf /var/lib/apt/lists/*; \
88
USER=root cargo new --bin app
99
WORKDIR /app
@@ -25,6 +25,7 @@ RUN touch .env;
2525
RUN rm -rf ./target/release/deps/stackdog*; \
2626
cargo build --release
2727

28+
2829
# deploy stage
2930
FROM debian:buster-slim
3031

@@ -43,5 +44,7 @@ COPY --from=build /app/.env .
4344
# expose port
4445
EXPOSE 5000
4546

47+
RUN /usr/bin/sqlite3 /app/db/stackdog.db
48+
4649
# run the binary
4750
ENTRYPOINT ["/app/stackdog"]

migrations/.gitkeep

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- This file was automatically created by Diesel to setup helper functions
2+
-- and other internal bookkeeping. This file is safe to edit, any future
3+
-- changes will be added to existing projects as new migrations.
4+
5+
DROP TRIGGER IF EXISTS UpdateTimestamps;
6+
DROP TABLE IF EXISTS users;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- Your SQL goes here
2+
CREATE TABLE users (
3+
id INTEGER PRIMARY KEY NOT NULL,
4+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
5+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
6+
username VARCHAR NOT NULL,
7+
email VARCHAR NOT NULL,
8+
password VARCHAR NOT NULL,
9+
login_session VARCHAR NOT NULL DEFAULT ''
10+
);
11+
12+
13+
CREATE TRIGGER IF NOT EXISTS UpdateTimestamps AFTER UPDATE ON users
14+
FOR EACH ROW WHEN NEW.updated_at <= OLD.updated_at
15+
BEGIN
16+
update users set updated_at=CURRENT_TIMESTAMP where id=OLD.id;
17+
END;

0 commit comments

Comments
 (0)