This commit is contained in:
Elijah McMorris 2023-06-30 05:11:31 +00:00
parent 3a34f6c1a3
commit 4306b99634
10 changed files with 105 additions and 41 deletions

9
.cargo/config.toml Normal file
View file

@ -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"

View file

@ -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 && \ RUN apt-get update && \
apt-get update && \ apt install -y build-essential xz-utils musl-tools musl-dev gcc-multilib pkg-config libssl-dev clang mold
apt install -y build-essential xz-utils musl-tools musl-dev gcc-multilib && \
rustup update
RUN LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+') && \ 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" && \ 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 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.]+') && \ 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 && \ sudo tar -xvf btop-x86_64-linux-musl.tbz && \
cd btop && ./install.sh && cd .. && \ cd btop && ./install.sh && cd .. && \
rm -rf btop-x86_64-linux-musl.tbz btop 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

View file

@ -22,6 +22,11 @@
"source": "devcontainer-cargo-cache-${containerWorkspaceFolderBasename}", "source": "devcontainer-cargo-cache-${containerWorkspaceFolderBasename}",
"target": "/usr/local/cargo", "target": "/usr/local/cargo",
"type": "volume" "type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-target",
"target": "${containerWorkspaceFolder}/target",
"type": "volume"
} }
], ],
// Features to add to the dev container. More info: https://containers.dev/features. // 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/git:1": {}
// "ghcr.io/devcontainers/features/nix:1": { // "ghcr.io/devcontainers/features/nix:1": {
// "packages": [ // "packages": [
// "btop" // "btop",
// // "lazygit" // "lazygit"
// ] // ]
// } // }
}, },
@ -40,10 +45,11 @@
// "postCreateCommand": { // "postCreateCommand": {
// }, // },
"postAttachCommand": { "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. // Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root", "remoteUser": "root",
"customizations": { "customizations": {
@ -55,7 +61,6 @@
"rust-lang.rust-analyzer", "rust-lang.rust-analyzer",
"mutantdino.resourcemonitor", "mutantdino.resourcemonitor",
"christian-kohler.path-intellisense", "christian-kohler.path-intellisense",
"Swellaby.vscode-rust-test-adapter",
"Gruntfuggly.todo-tree", "Gruntfuggly.todo-tree",
"ms-azuretools.vscode-docker", "ms-azuretools.vscode-docker",
"redhat.vscode-yaml" "redhat.vscode-yaml"

View file

@ -1,7 +1,8 @@
.dockerignore
/.devcontainer /.devcontainer
/.vscode
/target /target
.dockerignore
Cargo.lock Cargo.lock
docker-compose.yml
Dockerfile Dockerfile
README.md docker-compose.yml
*.md

1
.gitignore vendored
View file

@ -24,7 +24,6 @@ wheels/
.installed.cfg .installed.cfg
*.egg *.egg
MANIFEST MANIFEST
.vscode
# PyInstaller # PyInstaller
# Usually these files are written by a python script from a template # Usually these files are written by a python script from a template

43
.vscode/launch.json vendored Normal file
View file

@ -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}"
}
]
}

17
.vscode/settings.json vendored Normal file
View file

@ -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"
],
}

View file

@ -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 WORKDIR /ark-invest-api-rust
COPY . . 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 \ RUN --mount=type=cache,target=/usr/local/cargo,from=rust,source=/usr/local/cargo \
--mount=type=cache,target=./target \ --mount=type=cache,target=./target \
cargo build --target x86_64-unknown-linux-musl --release && \ 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 WORKDIR /ark-invest-api-rust

View file

@ -5,24 +5,7 @@ A REST API for ARK Invest holdings data, written in rust using [axum](https://gi
Not affiliated with Ark Invest Not affiliated with Ark Invest
# Install # Install
Copy docker-compose.yml
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)
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) 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 ## Docker Compose
`git clone` `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) 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` `docker compose build && docker compose up`

View file

@ -1,8 +1,8 @@
version: "3" version: "3"
services: services:
ark-invest-api-rust: ark-invest-api-rust:
# image: ghcr.io/NexVeridian/ark-invest-api-rust:latest image: ghcr.io/NexVeridian/ark-invest-api-rust:latest
image: ark-invest-api-rust # image: ark-invest-api-rust
build: build:
context: . context: .
args: args: