Add docker files
This commit is contained in:
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@ -0,0 +1,7 @@
|
||||
.venv
|
||||
.git
|
||||
.github
|
||||
**/.pytest_cache
|
||||
**/__pycache__
|
||||
.ruff_cache
|
||||
**/.testing
|
||||
30
docker/Dockerfile.admin
Normal file
30
docker/Dockerfile.admin
Normal file
@ -0,0 +1,30 @@
|
||||
# this Dockerfile should be built from the repo root
|
||||
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
|
||||
|
||||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
|
||||
ENV UV_PYTHON_DOWNLOADS=0
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY . /build
|
||||
|
||||
RUN uv build --package sshecret
|
||||
RUN uv build --package sshecret-admin
|
||||
|
||||
|
||||
FROM python:3.13-slim-bookworm
|
||||
|
||||
COPY --from=builder --chown=app:app /build/dist /opt/sshecret
|
||||
|
||||
RUN pip install /opt/sshecret/sshecret-*.whl
|
||||
RUN pip install /opt/sshecret/sshecret_admin-*.whl
|
||||
|
||||
EXPOSE 8822
|
||||
|
||||
VOLUME /opt/sshecret-admin
|
||||
|
||||
WORKDIR /opt/sshecret-admin
|
||||
|
||||
ENTRYPOINT [ "sshecret-admin" ]
|
||||
|
||||
CMD ["run", "--host", "0.0.0.0"]
|
||||
30
docker/Dockerfile.backend
Normal file
30
docker/Dockerfile.backend
Normal file
@ -0,0 +1,30 @@
|
||||
# this Dockerfile should be built from the repo root
|
||||
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
|
||||
|
||||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
|
||||
ENV UV_PYTHON_DOWNLOADS=0
|
||||
WORKDIR /build
|
||||
|
||||
COPY . /build
|
||||
|
||||
RUN uv build --package sshecret
|
||||
RUN uv build --package sshecret-backend
|
||||
|
||||
|
||||
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
|
||||
|
||||
COPY --from=builder --chown=app:app /build/dist /opt/sshecret
|
||||
|
||||
RUN uv pip install --system /opt/sshecret/sshecret-*.whl
|
||||
RUN uv pip install --system /opt/sshecret/sshecret_backend-*.whl
|
||||
|
||||
COPY packages/sshecret-backend /opt/sshecret-backend
|
||||
COPY docker/backend.entrypoint.sh /entrypoint.sh
|
||||
|
||||
WORKDIR /opt/sshecret-backend
|
||||
|
||||
VOLUME /opt/sshecret-backend-db
|
||||
|
||||
EXPOSE 8022
|
||||
|
||||
CMD ["/entrypoint.sh"]
|
||||
26
docker/Dockerfile.sshd
Normal file
26
docker/Dockerfile.sshd
Normal file
@ -0,0 +1,26 @@
|
||||
# this Dockerfile should be built from the repo root
|
||||
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
|
||||
|
||||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
|
||||
ENV UV_PYTHON_DOWNLOADS=0
|
||||
WORKDIR /build
|
||||
|
||||
COPY . /build
|
||||
|
||||
RUN uv build --package sshecret
|
||||
RUN uv build --package sshecret-sshd
|
||||
|
||||
FROM python:3.13-slim-bookworm
|
||||
|
||||
COPY --from=builder --chown=app:app /build/dist /opt/sshecret
|
||||
|
||||
RUN pip install /opt/sshecret/sshecret-*.whl
|
||||
RUN pip install /opt/sshecret/sshecret_sshd-*.whl
|
||||
|
||||
WORKDIR /opt/sshecret-sshd
|
||||
|
||||
VOLUME /opt/sshecret-sshd
|
||||
|
||||
EXPOSE 2222
|
||||
|
||||
CMD ["sshecret-sshd", "run", "--host", "0.0.0.0"]
|
||||
15
docker/backend.entrypoint.sh
Executable file
15
docker/backend.entrypoint.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
fail() {
|
||||
printf '%s\n' "$1" >&2 ## Send message to stderr.
|
||||
exit "${2-1}" ## Return a code specified by $2, or 1 by default.
|
||||
}
|
||||
|
||||
[[ -d migrations ]] || fail "Error: Must be run from the backend directory."
|
||||
[[ -d /opt/sshecret-backend-db ]] || mkdir /opt/sshecret-backend-db
|
||||
|
||||
export SSHECRET_BACKEND_DATABASE="/opt/sshecret-backend-db/sshecret.db"
|
||||
|
||||
alembic upgrade head
|
||||
|
||||
sshecret-backend run --host 0.0.0.0
|
||||
19
docker/docker-compose.yml
Normal file
19
docker/docker-compose.yml
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
|
||||
services:
|
||||
backend:
|
||||
image: sshecret-backend
|
||||
container_name: sshecret_backend
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: dockerfile.backend
|
||||
networks:
|
||||
- common
|
||||
volumes:
|
||||
- backend_data
|
||||
|
||||
volumes:
|
||||
backend_data:
|
||||
|
||||
networks:
|
||||
common:
|
||||
Reference in New Issue
Block a user