feat: dockerize application
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2026-01-09 14:34:27 +01:00
parent d34b7361cb
commit 4557231256
3 changed files with 65 additions and 21 deletions

View File

@@ -7,34 +7,47 @@ platform:
steps: steps:
- name: build-release - name: build-release
image: rust:1.91 image: rust:1.92
commands: commands:
- cargo build --verbose --workspace --release - cargo build --verbose --workspace --release
- name: test - name: test
image: rust:1.91 image: rust:1.92
commands: commands:
- cargo test --verbose --workspace - cargo test --verbose --workspace
- name: lint - name: lint
image: rust:1.91 image: rust:1.92
commands: commands:
- rustup component add clippy - rustup component add clippy
- cargo clippy --all-targets --all-features - cargo clippy --all-targets --all-features
- name: push-binary-release - name: format
image: plugins/gitea-release image: rust:1.92
commands:
- rustup component add rustfmt
- cargo fmt --all -- --check
- name: build-image
image: plugins/docker
settings: settings:
base_url: https://gitea.lardenois.cc repo: gitea.lardenois.cc/jerem/nats-test
api_key: tags: latest
from_secret: gitea-package dockerfile: Dockerfile
files: dry_run: "true"
- target/release/pg-instance-handler
title: "Release ${DRONE_TAG:-v${DRONE_BUILD_NUMBER}}"
note: "Automated release from commit ${DRONE_COMMIT_SHA}"
checksum:
- sha256
when: when:
event: tag branch:
status: success exclude:
depends_on: - main
- build-release - name: build-and-push-image
- test image: plugins/docker
- lint settings:
registry: gitea.lardenois.cc
repo: gitea.lardenois.cc/matos-ai/pg-instance-handler
tags:
- latest
dockerfile: Dockerfile
username:
from_secret: GITEA_USER
password:
from_secret: GITEA_PASSWORD
when:
branch:
include:
- main

17
Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
FROM rust:1.92 AS builder
RUN rustup target add x86_64-unknown-linux-musl
RUN apt-get update && apt-get install -y musl-tools && rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
COPY ./Cargo.toml ./Cargo.lock ./
COPY ./src ./src
RUN cargo build --release --target x86_64-unknown-linux-musl
FROM scratch
COPY --from=builder /usr/src/app/target/x86_64-unknown-linux-musl/release/pg-instance-handler /pg-instance-handler
CMD ["/pg-instance-handler"]

View File

@@ -11,3 +11,17 @@ services:
interval: 5s interval: 5s
timeout: 5s timeout: 5s
retries: 5 retries: 5
pg-instance-handler:
build:
context: .
dockerfile: Dockerfile
depends_on:
postgres:
condition: service_healthy
environment:
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
ports:
- "8080:8080"
volumes:
- ./database.txt:/database.txt:ro