Compare commits
2 Commits
8d95b79db6
...
4557231256
| Author | SHA1 | Date | |
|---|---|---|---|
| 4557231256 | |||
| d34b7361cb |
53
.drone.yml
53
.drone.yml
@@ -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
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"]
|
||||||
@@ -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
|
||||||
@@ -70,6 +70,9 @@ impl ForManagingDatabases for SQLXHandler {
|
|||||||
.execute(&pool)
|
.execute(&pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("create database failed: {}", e))?;
|
.map_err(|e| format!("create database failed: {}", e))?;
|
||||||
|
|
||||||
|
info!(database = %ident, "Database created");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -98,6 +101,9 @@ impl ForManagingDatabases for SQLXHandler {
|
|||||||
.execute(&pool)
|
.execute(&pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("drop database failed: {}", e))?;
|
.map_err(|e| format!("drop database failed: {}", e))?;
|
||||||
|
|
||||||
|
info!(database = %ident, "Database deleted");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user