index : license-api-rs.git

ascending towards madness

author holly sparkles <sparkles@holly.sh> 2023-10-10 20:04:54.0 +00:00:00
committer holly sparkles <sparkles@holly.sh> 2023-10-10 20:04:54.0 +00:00:00
commit
5a0277d1cef2b288b9a7c8e0a7f9f39f20e3ba93 [patch]
tree
232ab70f340b4f9d19fd4b9b1f7bfe1ff1e7bad7
parent
bdf4bdd8fcf364cee197720a4c00ff4f044bba34
download
5a0277d1cef2b288b9a7c8e0a7f9f39f20e3ba93.tar.gz

feat: add docker support



Diff

 Dockerfile         | 14 ++++++++++++++
 README.md          | 10 ++++++++++
 docker-compose.yml | 11 +++++++++++
 3 files changed, 35 insertions(+)

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..7de70a4
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,14 @@
FROM rust:1.73-slim AS builder

RUN apt-get update && apt-get install -y libssl-dev pkg-config

COPY . /sources
WORKDIR /sources
RUN rustup target add x86_64-unknown-linux-musl 
RUN cargo build --target x86_64-unknown-linux-musl --release

FROM alpine:3.16
COPY --from=builder /sources/target/x86_64-unknown-linux-musl/release/license-api-rs /lapi

EXPOSE 8080
ENTRYPOINT ["/lapi"]
diff --git a/README.md b/README.md
index 07ed65a..b1b8e89 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,16 @@ export LICENSE_API_WELCOME_MESSAGE="/path/to/welcome.txt"

All environment variables except for `LICENSE_API_DATABASE` are optional. If `LICENSE_API_DATABASE` is not set, the server will refuse to start.

## Docker

This project has first-class Docker support. I prefer to not pull my images from a repository, as that leaves one vulnerable to supply chain attacks. To build the Docker image, simply run `docker build -t lapi:latest .` in the repository directory.

I am using [Alpine]https://hub.docker.com/_/alpine/ as a base image, and the application is built using the `x86_64-unknown-linux-musl` [build target]https://blog.rust-lang.org/2023/05/09/Updating-musl-targets.html.

A sample `docker-compose.yml` file is also included.

On my home server, this service uses 964 KB of RAM with my license database, so it is lightweight.

## License

- [AGPL 3.0]LICENSE
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..7695b4a
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,11 @@
version: '3'
services:
  lapi:
    image: lapi:latest
    volumes:
      - /path/to/my/data/:/config
    environment:
      - LICENSE_API_DATABASE=/config/licenses/database.yml
    ports:
      - 3535:8080
    restart: unless-stopped