From 4306b9963458ee1084eddf1bc7e22e38d81fae58 Mon Sep 17 00:00:00 2001 From: "NexVeridian@gmail.com" Date: Fri, 30 Jun 2023 05:11:31 +0000 Subject: [PATCH] 1.1.0 --- .cargo/config.toml | 9 +++++++ .devcontainer/Dockerfile | 14 ++++++----- .devcontainer/devcontainer.json | 15 ++++++++---- .dockerignore | 7 +++--- .gitignore | 1 - .vscode/launch.json | 43 +++++++++++++++++++++++++++++++++ .vscode/settings.json | 17 +++++++++++++ Dockerfile | 15 +++++++++--- README.md | 21 +--------------- docker-compose.yml | 4 +-- 10 files changed, 105 insertions(+), 41 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..0a0833d --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,9 @@ +[target.x86_64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/mold"] + +[alias] +t = "nextest run" + +[build] +target-dir = "target/target" diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 34d2cc0..fd359e1 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,9 +1,8 @@ -FROM mcr.microsoft.com/devcontainers/rust:bullseye +# https://mcr.microsoft.com/en-us/product/devcontainers/rust/about +FROM mcr.microsoft.com/devcontainers/rust:bookworm -RUN rustup target add x86_64-unknown-linux-musl && \ - apt-get update && \ - apt install -y build-essential xz-utils musl-tools musl-dev gcc-multilib && \ - rustup update +RUN apt-get update && \ + apt install -y build-essential xz-utils musl-tools musl-dev gcc-multilib pkg-config libssl-dev clang mold RUN LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+') && \ curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" && \ @@ -11,7 +10,10 @@ RUN LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygi rm -rf lazygit.tar.gz RUN BTOP_VERSION=$(curl -s "https://api.github.com/repos/aristocratos/btop/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+') && \ - wget "https://github.com/aristocratos/btop/releases/download/${BTOP_VERSION}/btop-x86_64-linux-musl.tbz" && \ + wget "https://github.com/aristocratos/btop/releases/download/v${BTOP_VERSION}/btop-x86_64-linux-musl.tbz" && \ sudo tar -xvf btop-x86_64-linux-musl.tbz && \ cd btop && ./install.sh && cd .. && \ rm -rf btop-x86_64-linux-musl.tbz btop + +RUN curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin +# cargo install cargo-nextest --locked diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6c1c4ca..3c4eea0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -22,6 +22,11 @@ "source": "devcontainer-cargo-cache-${containerWorkspaceFolderBasename}", "target": "/usr/local/cargo", "type": "volume" + }, + { + "source": "${localWorkspaceFolderBasename}-target", + "target": "${containerWorkspaceFolder}/target", + "type": "volume" } ], // Features to add to the dev container. More info: https://containers.dev/features. @@ -29,8 +34,8 @@ "ghcr.io/devcontainers/features/git:1": {} // "ghcr.io/devcontainers/features/nix:1": { // "packages": [ - // "btop" - // // "lazygit" + // "btop", + // "lazygit" // ] // } }, @@ -40,10 +45,11 @@ // "postCreateCommand": { // }, "postAttachCommand": { - "AddGitSafeDir": "git config --global --add safe.directory /workspaces/${containerWorkspaceFolderBasename}" + "AddGitSafeDir": "git config --global --add safe.directory /workspaces/${containerWorkspaceFolderBasename}", + "update": "rustup target add x86_64-unknown-linux-musl && rustup update && cargo update", + "clippy": "cargo clippy --fix --allow-dirty" }, // Configure tool-specific properties. - // "customizations": {}, // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. "remoteUser": "root", "customizations": { @@ -55,7 +61,6 @@ "rust-lang.rust-analyzer", "mutantdino.resourcemonitor", "christian-kohler.path-intellisense", - "Swellaby.vscode-rust-test-adapter", "Gruntfuggly.todo-tree", "ms-azuretools.vscode-docker", "redhat.vscode-yaml" diff --git a/.dockerignore b/.dockerignore index ecc5c8b..729d6d6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,8 @@ -.dockerignore /.devcontainer +/.vscode /target +.dockerignore Cargo.lock -docker-compose.yml Dockerfile -README.md +docker-compose.yml +*.md diff --git a/.gitignore b/.gitignore index b089282..270d0b9 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,6 @@ wheels/ .installed.cfg *.egg MANIFEST -.vscode # PyInstaller # Usually these files are written by a python script from a template diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..5e7d094 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,43 @@ +{ + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug executable 'ark-invest-api-rust-data'", + "cargo": { + "args": [ + "build", + "--bin=ark-invest-api-rust-data", + "--package=ark-invest-api-rust-data" + ], + "filter": { + "name": "ark-invest-api-rust-data", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in executable 'ark-invest-api-rust-data'", + "cargo": { + "args": [ + "test", + "--no-run", + "--bin=ark-invest-api-rust-data", + "--package=ark-invest-api-rust-data" + ], + "filter": { + "name": "ark-invest-api-rust-data", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..dfc4962 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,17 @@ +{ + "[Rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer", + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "file" + }, + "rust-analyzer.check.command": "clippy", + "rust-analyzer.cargo.buildScripts.overrideCommand": [ + "cargo", + "clippy", + "--fix", + "--workspace", + "--message-format=json", + "--all-targets", + "--allow-dirty" + ], +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5258f25..a3f66db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,24 @@ -FROM rust:latest AS builder +FROM rust:bookworm AS builder -RUN rustup target add x86_64-unknown-linux-musl && apt update && apt install -y musl-tools musl-dev +RUN apt-get update && \ + apt install -y musl-tools musl-dev libssl-dev clang mold + +# RUN curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin +RUN curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C /usr/local/bin +# RUN cargo install cargo-nextest --locked WORKDIR /ark-invest-api-rust COPY . . +RUN rustup target add x86_64-unknown-linux-musl && rustup update && cargo update + RUN --mount=type=cache,target=/usr/local/cargo,from=rust,source=/usr/local/cargo \ --mount=type=cache,target=./target \ cargo build --target x86_64-unknown-linux-musl --release && \ - cp ./target/x86_64-unknown-linux-musl/release/ark-invest-api-rust . + cp ./target/target/x86_64-unknown-linux-musl/release/ark-invest-api-rust . -FROM alpine:latest +FROM alpine:latest AS main WORKDIR /ark-invest-api-rust diff --git a/README.md b/README.md index 846cc96..56a2937 100644 --- a/README.md +++ b/README.md @@ -5,24 +5,7 @@ A REST API for ARK Invest holdings data, written in rust using [axum](https://gi Not affiliated with Ark Invest # Install - -Create docker-compose.yml -``` -version: "3" -services: - ark-invest-api-rust: - image: ghcr.io/nexveridian/ark-invest-api-rust:latest - container_name: ark-invest-api-rust - restart: unless-stopped - volumes: - - ./data:/ark-invest-api-rust/data - ports: - - "3000:3000" - -volumes: - data: -``` -Recomended: add nginx-certbot to the docker-compose file, [GitHub](https://github.com/JonasAlfredsson/docker-nginx-certbot#run-with-docker-compose), [Docker Hub](https://hub.docker.com/r/jonasal/nginx-certbot) +Copy docker-compose.yml Create data folder next to docker-compose.yml, `data\parquet\*.parquet` with the ticker in all caps `ARKK.parquet`, get the data from [api.NexVeridian.com](https://api.NexVeridian.com) or [ark-invest-api-rust-data](https://github.com/NexVeridian/ark-invest-api-rust-data) @@ -50,8 +33,6 @@ Place data in `data\parquet\*.parquet` with the ticker in all caps `ARKK.parquet ## Docker Compose `git clone` -Recomended: add nginx-certbot to the docker-compose file, [GitHub](https://github.com/JonasAlfredsson/docker-nginx-certbot#run-with-docker-compose), [Docker Hub](https://hub.docker.com/r/jonasal/nginx-certbot) - Place data in `data\parquet\*.parquet` with the ticker in all caps `ARKK.parquet`, get the data from [api.NexVeridian.com](https://api.NexVeridian.com) or [ark-invest-api-rust-data](https://github.com/NexVeridian/ark-invest-api-rust) `docker compose build && docker compose up` diff --git a/docker-compose.yml b/docker-compose.yml index b4eb164..23d94b2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,8 @@ version: "3" services: ark-invest-api-rust: - # image: ghcr.io/NexVeridian/ark-invest-api-rust:latest - image: ark-invest-api-rust + image: ghcr.io/NexVeridian/ark-invest-api-rust:latest + # image: ark-invest-api-rust build: context: . args: