Skip to content

Commit

Permalink
feat: add docker compose support (#463)
Browse files Browse the repository at this point in the history
* Fix workspace definition.

Do not mix with package definition.

* Move fixtures folder.

* Ignore failing CI test on windows.

* Fix fixtures path.

* Update paths.

* Tweak Makefile, paths for CLI tests.

* Reduce dependencies when building server code.

* Add docker compose file.

* Update README.

* Fix license checks.
  • Loading branch information
tmpfs committed Jun 21, 2024
1 parent 8686c0a commit 188ee7f
Show file tree
Hide file tree
Showing 284 changed files with 196 additions and 269 deletions.
62 changes: 31 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 2 additions & 54 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
[package]
name = "sos-workspace"
version = "0.14.1"
edition = "2021"
rust-version = "1.78.0"
description = "Distributed, encrypted database for private secrets."
homepage = "https://saveoursecrets.com"
license = "MIT OR Apache-2.0 OR AGPL-3.0"
authors = ["saveoursecrets-developers <dev@saveoursecrets.com>"]
publish = false
categories = [
"command-line-utilities",
"cryptography::cryptocurrencies",
"authentication"
]

[workspace]
resolver = "2"
members = [
"crates/artifact",
"crates/cli_helpers",
"crates/cli_helpers",
"crates/keychain_parser",
"crates/integration_tests",
"crates/net",
"crates/protocol",
"crates/sdk",
Expand All @@ -29,10 +14,6 @@ members = [
"crates/vfs",
]

[features]
default = []
enable-cli-tests = []

[workspace.dependencies]
csv-async = { version = "1", features = ["tokio", "with_serde"] }
thiserror = "1"
Expand Down Expand Up @@ -81,39 +62,6 @@ version = "9.1.0"
features = ["async"]
#path = "../../../../binary-stream"

[dev-dependencies]
binary-stream.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
serde_json.workspace = true
thiserror.workspace = true
async-recursion.workspace = true
futures.workspace = true
parking_lot.workspace = true
once_cell.workspace = true
serde.workspace = true
clap.workspace = true
indexmap.workspace = true
tokio.workspace = true
anyhow.workspace = true
secrecy.workspace = true
http.workspace = true

sos-server = { path = "crates/server" }
sos_test_utils = { path = "crates/test_utils" }

copy_dir = "0.1"
maplit2 = "1"
tempfile = "3.5"
kdam = { version = "0.5", features = ["rich", "spinner"] }
pretty_assertions = "1.4"
anticipate-runner = { version = "0.5.1" }

[dev-dependencies.sos-net]
version = "0.14.0"
features = ["full"]
path = "crates/net"

[profile.release]
codegen-units = 1
lto = true
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM rust:1.78-buster AS rust
FROM rust:latest as builder

WORKDIR /usr/app

COPY crates crates
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock
ENV CARGO_HOME /usr/app
ENV PATH="/usr/app/bin:${PATH}"

COPY sandbox/config.toml config.toml
RUN mkdir accounts
RUN cargo build --locked --release -p sos-server
RUN cargo install --locked sos-server

CMD /usr/app/target/release/sos-server start /usr/app/config.toml
CMD sos-server start /usr/app/config.toml
95 changes: 8 additions & 87 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,11 @@ args = ["fmt"]
command = "cargo"
args = ["fmt", "--all", "--", "--check"]

[tasks.check]
workspace = true
command = "cargo"
args = ["check"]

[tasks.clippy]
workspace = true
command = "cargo"
args = ["clippy", "--all-features"]

[tasks.clean]
workspace = true
command = "cargo"
args = ["clean"]

[tasks.build]
workspace = true
command = "cargo"
Expand Down Expand Up @@ -69,55 +59,18 @@ dependencies = ["clean-doc"]
command = "cargo"
args = ["test", "--all", "--lib"]

[tasks.test-audit-trail]
command = "cargo"
args = ["test", "audit"]

[tasks.test-backup-archive]
command = "cargo"
args = ["test", "backup_archive"]

[tasks.test-command-line]
command = "cargo"
args = ["test", "command_line", "--features", "enable-cli-tests", "--", "--nocapture"]
args = [
"test",
"command_line",
"--features",
"enable-cli-tests",
"--",
"--nocapture",
]
dependencies = ["clean-cli"]

[tasks.test-event-log]
command = "cargo"
args = ["test", "event_log_"]

[tasks.test-diff-merge]
command = "cargo"
args = ["test", "diff_merge_"]

[tasks.test-local-account]
command = "cargo"
args = ["test", "local_"]

[tasks.test-network-account]
command = "cargo"
args = ["test", "network_"]

[tasks.test-pairing]
command = "cargo"
args = ["test", "pairing_"]

[tasks.test-file-transfers]
command = "cargo"
args = ["test", "file_transfers_"]

[tasks.test-access-control]
command = "cargo"
args = ["test", "access_control_"]

[tasks.test-preferences]
command = "cargo"
args = ["test", "preferences_"]

[tasks.test-system-messages]
command = "cargo"
args = ["test", "system_messages_"]

[tasks.clean-cli]
script_runner = "@shell"
script = '''
Expand Down Expand Up @@ -151,38 +104,6 @@ command = "cargo"
args = ["test", "--all"]
dependencies = ["clean-cli"]

[tasks.dev]
dependencies = ["check-wasm", "test", "format"]

[tasks.check-wasm-node-client]
command = "cargo"
args = [
"check",
"--target",
"wasm32-unknown-unknown",
"-p",
"sos-net",
"--no-default-features",
"--features",
"client"
]

[tasks.check-wasm]
command = "cargo"
args = ["check", "--target", "wasm32-unknown-unknown", "-p", "sos-sdk"]
dependencies = ["check-wasm-node-client"]

[tasks.dev-server]
script = '''
cargo run --bin sos-server -- start sandbox/config.toml
'''

[tasks.dev-certs]
script = '''
command -v mkcert && cd sandbox &&
mkcert -key-file key.pem -cert-file cert.pem localhost 127.0.0.1 ::1
'''

[tasks.genhtml]
script = '''
grcov ${COVERAGE_PROF_OUTPUT} -s . --binary-path ./target/cover/debug -t html --branch --ignore-not-existing -o ./target/coverage/ --ignore 'workspace/*/build.rs' --ignore 'tests/*' --ignore 'target/*'
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ To see the code in action [download the app](https://saveoursecrets.com/#downloa

See the [overview](/doc/overview.md) for concepts and terminology, the [API documentation for the SDK](https://docs.rs/sos-sdk/latest/sos_sdk/) or the [API documentation for the networking library](https://docs.rs/sos-net/latest/sos_net/).

## Server

The server can be run using docker writing account data to the `sandbox/accounts` directory:

```
docker compose up
```

## License

The server code is licensed under AGPL-3.0; other crates are licensed under the MIT or Apache-2.0 license at your discretion.
Expand Down
8 changes: 8 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
web:
build:
target: builder
ports:
- '5053:5053'
volumes:
- ./sandbox/accounts:/usr/app/accounts
44 changes: 44 additions & 0 deletions crates/integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "sos-integration-tests"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
publish = false

[features]
default = []
enable-cli-tests = []

[dev-dependencies]
binary-stream.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
serde_json.workspace = true
thiserror.workspace = true
async-recursion.workspace = true
futures.workspace = true
parking_lot.workspace = true
once_cell.workspace = true
serde.workspace = true
clap.workspace = true
indexmap.workspace = true
tokio.workspace = true
anyhow.workspace = true
secrecy.workspace = true
http.workspace = true

sos-server = { path = "../server" }
sos_test_utils = { path = "../test_utils" }

copy_dir = "0.1"
maplit2 = "1"
tempfile = "3.5"
kdam = { version = "0.5", features = ["rich", "spinner"] }
pretty_assertions = "1.4"
anticipate-runner = { version = "0.5.1" }

[dev-dependencies.sos-net]
version = "0.14.0"
features = ["full"]
path = "../net"

2 changes: 2 additions & 0 deletions crates/integration_tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//! Stub file.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ async fn simulate_session(
let unsafe_archive = "target/audit-trail-unsafe-archive.zip";
account.export_unsafe_archive(unsafe_archive).await?;

let import_file = "tests/fixtures/migrate/bitwarden-export.csv";
let import_file = "../../fixtures/migrate/bitwarden-export.csv";
let import_target = ImportTarget {
format: "bitwarden.csv".parse()?,
path: PathBuf::from(import_file),
folder_name: "Bitwarden folder".to_string(),
};
account.import_file(import_target).await?;

let contacts = "tests/fixtures/contacts.vcf";
let contacts = "../../fixtures/contacts.vcf";
let vcard = vfs::read_to_string(contacts).await?;
account.import_contacts(&vcard, |_| {}).await?;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 188ee7f

Please sign in to comment.