chore: add Dockerfile & ci for publishing dev images
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/clippy Pipeline failed Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docker Pipeline failed Details

db-centric-repos
Jef Roosens 2023-08-05 12:23:15 +02:00
parent e5be439178
commit 86cd52a081
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
5 changed files with 64 additions and 24 deletions

View File

@ -2,3 +2,5 @@ target/
.git/
server/data/
server/test.db/
Dockerfile
docker-compose.yml

View File

@ -0,0 +1,20 @@
branches: [dev]
platform: 'linux/amd64'
depends_on:
- build
pipeline:
dev:
image: 'woodpeckerci/plugin-docker-buildx'
secrets:
- 'docker_username'
- 'docker_password'
settings:
registry: 'git.rustybever.be'
repo: 'git.rustybever.be/chewing_bever/rieter'
tags:
- 'dev'
platforms: [ 'linux/amd64' ]
when:
event: push
branch: dev

View File

@ -4,21 +4,6 @@ ARG DI_VER=1.2.5
WORKDIR /app
# RUN apk add --no-cache \
# build-base \
# curl \
# make \
# unzip \
# pkgconf \
# openssl openssl-libs-static openssl-dev \
# libarchive-static libarchive-dev \
# zlib-static zlib-dev \
# bzip2-static bzip2-dev \
# xz-static xz-dev \
# expat-static expat-dev \
# zstd-static zstd-dev \
# lz4-static lz4-dev \
# acl-static acl-dev
RUN apk add --no-cache \
build-base \
curl \
@ -42,23 +27,29 @@ COPY . .
# LIBARCHIVE_LDFLAGS='-lssl -lcrypto -L/lib -lz -lbz2 -llzma -lexpat -lzstd -llz4'
# LIBARCHIVE_LDFLAGS='-L/usr/lib -lz -lbz2 -llzma -lexpat -lzstd -llz4 -lsqlite3'
# https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172
ENV RUSTFLAGS='-C target-feature=-crt-static'
RUN cargo build --release && \
du -h target/release/rieterd && \
readelf -d target/release/rieterd && \
chmod +x target/release/rieterd
# [ "$(readelf -d target/debug/rieterd | grep NEEDED | wc -l)" = 0 ] && \
# chmod +x target/debug/rieterd
FROM alpine:3.18
WORKDIR /app
RUN apk add --no-cache \
libarchive
libgcc \
libarchive \
openssl
COPY --from=builder /app/dumb-init /bin/dumb-init
COPY --from=builder /app/target/debug/rieterd /bin/rieterd
COPY --from=builder /app/target/release/rieterd /bin/rieterd
ENV RIETER_PKG_DIR=/data/pkgs \
RIETER_DATA_DIR=/data
WORKDIR /data
ENTRYPOINT ["/bin/dumb-init", "--"]
CMD ["/bin/rieterd"]

17
docker-compose.yml 100644
View File

@ -0,0 +1,17 @@
version: '3.4'
services:
app:
image: 'rieterd:latest'
ports:
- '8000:8000'
environment:
- 'RIETER_API_KEY=test'
- 'RIETER_DATABASE_URL=postgres://rieter:rieter@db:5432/rieter'
db:
image: 'postgres:15.3-alpine'
environment:
- 'POSTGRES_DB=rieter'
- 'POSTGRES_USER=rieter'
- 'POSTGRES_PASSWORD=rieter'

View File

@ -15,24 +15,34 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
#[command(author, version, about, long_about = None)]
pub struct Cli {
/// Directory where package archives will be stored
#[arg(env = "RIETER_PKG_DIR")]
pub pkg_dir: PathBuf,
/// Directory where repository metadata & SQLite database is stored
#[arg(env = "RIETER_DATA_DIR")]
pub data_dir: PathBuf,
/// API key to authenticate private routes with
#[arg(env = "RIETER_API_KEY")]
pub api_key: String,
/// Database connection URL; either sqlite:// or postgres://. Defaults to rieter.sqlite in the
/// data directory
#[arg(short, long)]
#[arg(short, long, env = "RIETER_DATABASE_URL")]
pub database_url: Option<String>,
/// Port the server will listen on
#[arg(short, long, value_name = "PORT", default_value_t = 8000)]
#[arg(
short,
long,
value_name = "PORT",
default_value_t = 8000,
env = "RIETER_PORT"
)]
pub port: u16,
/// Log levels for the tracing
#[arg(
long,
value_name = "LOG_LEVEL",
default_value = "tower_http=debug,rieterd=debug"
default_value = "tower_http=debug,rieterd=debug",
env = "RIETER_LOG"
)]
pub log: String,
}