feat: add docker support
Diff
Dockerfile | 14 ++++++++++++++
README.md | 10 ++++++++++
docker-compose.yml | 11 +++++++++++
3 files changed, 35 insertions(+)
@@ -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"]
@@ -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)
@@ -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