Compare commits
2 Commits
8d95b79db6
...
4557231256
| Author | SHA1 | Date | |
|---|---|---|---|
| 4557231256 | |||
| d34b7361cb |
53
.drone.yml
53
.drone.yml
@@ -7,34 +7,47 @@ platform:
|
||||
|
||||
steps:
|
||||
- name: build-release
|
||||
image: rust:1.91
|
||||
image: rust:1.92
|
||||
commands:
|
||||
- cargo build --verbose --workspace --release
|
||||
- name: test
|
||||
image: rust:1.91
|
||||
image: rust:1.92
|
||||
commands:
|
||||
- cargo test --verbose --workspace
|
||||
- name: lint
|
||||
image: rust:1.91
|
||||
image: rust:1.92
|
||||
commands:
|
||||
- rustup component add clippy
|
||||
- cargo clippy --all-targets --all-features
|
||||
- name: push-binary-release
|
||||
image: plugins/gitea-release
|
||||
- name: format
|
||||
image: rust:1.92
|
||||
commands:
|
||||
- rustup component add rustfmt
|
||||
- cargo fmt --all -- --check
|
||||
- name: build-image
|
||||
image: plugins/docker
|
||||
settings:
|
||||
base_url: https://gitea.lardenois.cc
|
||||
api_key:
|
||||
from_secret: gitea-package
|
||||
files:
|
||||
- target/release/pg-instance-handler
|
||||
title: "Release ${DRONE_TAG:-v${DRONE_BUILD_NUMBER}}"
|
||||
note: "Automated release from commit ${DRONE_COMMIT_SHA}"
|
||||
checksum:
|
||||
- sha256
|
||||
repo: gitea.lardenois.cc/jerem/nats-test
|
||||
tags: latest
|
||||
dockerfile: Dockerfile
|
||||
dry_run: "true"
|
||||
when:
|
||||
event: tag
|
||||
status: success
|
||||
depends_on:
|
||||
- build-release
|
||||
- test
|
||||
- lint
|
||||
branch:
|
||||
exclude:
|
||||
- main
|
||||
- name: build-and-push-image
|
||||
image: plugins/docker
|
||||
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
17
Dockerfile
Normal 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"]
|
||||
@@ -10,4 +10,18 @@ services:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 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
|
||||
@@ -70,6 +70,9 @@ impl ForManagingDatabases for SQLXHandler {
|
||||
.execute(&pool)
|
||||
.await
|
||||
.map_err(|e| format!("create database failed: {}", e))?;
|
||||
|
||||
info!(database = %ident, "Database created");
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
@@ -98,6 +101,9 @@ impl ForManagingDatabases for SQLXHandler {
|
||||
.execute(&pool)
|
||||
.await
|
||||
.map_err(|e| format!("drop database failed: {}", e))?;
|
||||
|
||||
info!(database = %ident, "Database deleted");
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user