added docker as an example
This commit is contained in:
parent
0901edf8eb
commit
2414e01f8b
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
# Nix builder
|
||||
FROM nixos/nix:latest AS builder
|
||||
|
||||
# Copy our source and setup our working dir.
|
||||
COPY . /tmp/build
|
||||
WORKDIR /tmp/build
|
||||
|
||||
# Build our Nix environment
|
||||
RUN nix \
|
||||
--extra-experimental-features "nix-command flakes" \
|
||||
--option filter-syscalls false \
|
||||
build
|
||||
|
||||
# Copy the Nix store closure into a directory. The Nix store closure is the
|
||||
# entire set of Nix store values that we need for our build.
|
||||
RUN mkdir /tmp/nix-store-closure
|
||||
RUN cp -r $(nix-store -qR result/) /tmp/nix-store-closure
|
||||
|
||||
# Final image is based on scratch. We copy a bunch of Nix dependencies
|
||||
# but they're fully self-contained so we don't need Nix anymore.
|
||||
FROM scratch
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy /nix/store
|
||||
COPY --from=builder /tmp/nix-store-closure /nix/store
|
||||
COPY --from=builder /tmp/build/result /app
|
||||
CMD ["/app/bin/testdata"]
|
15
docker-compose.yaml
Normal file
15
docker-compose.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
services:
|
||||
testdata:
|
||||
image: result/latest
|
||||
|
||||
build:
|
||||
dockerfile: ./Dockerfile
|
||||
|
||||
environment:
|
||||
TESTDATA_HOST: 0.0.0.0
|
||||
TESTDATA_PORT: 1234
|
||||
TESTDATA_CONFIG: ./config.json
|
||||
volumes:
|
||||
- ./config.json:/app/config.json
|
||||
- ./db.json:/app/db.json
|
||||
- ./log.jsonl:/app/log.jsonl
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "testdata"
|
||||
version = "1.1.0"
|
||||
version = "1.2.0"
|
||||
requires-python = "~=3.12, <4"
|
||||
dependencies = [
|
||||
"fastapi~=0.115.3",
|
||||
@ -31,7 +31,7 @@ where = ["src"]
|
||||
testdata = ["py.typed"]
|
||||
|
||||
[tool.autopep8]
|
||||
max_line_length = 175
|
||||
max_line_length = 150
|
||||
|
||||
[tool.pylint.'MESSAGES CONTROL']
|
||||
disable = [
|
||||
|
19
src/testdata/main.py
vendored
19
src/testdata/main.py
vendored
@ -1,3 +1,4 @@
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import asyncio
|
||||
@ -11,9 +12,21 @@ def parse_args(args: list[str]):
|
||||
|
||||
parser = argparse.ArgumentParser(formatter_class=formatter)
|
||||
|
||||
parser.add_argument('-c', '--config', type=argparse.FileType('r'), default='./config.json', help='Path to config file in JSON format.', )
|
||||
parser.add_argument('-l', '--listen', type=str, default='0.0.0.0', help='IP on which to listen.')
|
||||
parser.add_argument('-p', '--port', type=int, default='8080', help='Port on which to serve the webserver.')
|
||||
parser.add_argument(
|
||||
'-c', '--config', type=argparse.FileType('r'),
|
||||
default=os.environ['TESTDATA_CONFIG'] if 'TESTDATA_CONFIG' in os.environ else './config.json',
|
||||
help='Path to config file in JSON format.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-l', '--listen', type=str,
|
||||
default=os.environ['TESTDATA_HOST'] if 'TESTDATA_HOST' in os.environ else '0.0.0.0',
|
||||
help='IP on which to listen.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-p', '--port', type=int,
|
||||
default=os.environ['TESTDATA_PORT'] if 'TESTDATA_PORT' in os.environ else 8080,
|
||||
help='Port on which to serve the webserver.'
|
||||
)
|
||||
|
||||
return parser.parse_args(args)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user