refactoring
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Robert Kaussow 2020-02-22 17:32:27 +01:00
parent 569f9eb837
commit 9ad6505c39
6 changed files with 73 additions and 73 deletions

View File

@ -1,5 +1,4 @@
local PipelineBuild(arch='amd64') = { local PipelineBuild(arch='amd64') = {
local tag = 'linux-' + arch,
kind: 'pipeline', kind: 'pipeline',
name: 'build-container-' + arch, name: 'build-container-' + arch,
platform: { platform: {
@ -11,27 +10,19 @@ local PipelineBuild(arch='amd64') = {
name: 'binary', name: 'binary',
image: 'clux/muslrust:nightly-2019-12-19', image: 'clux/muslrust:nightly-2019-12-19',
environment: { environment: {
DB: 'postgresql', BUILD_VERSION: '${DRONE_TAG%-*}',
DEBIAN_FRONTEND: 'noninteractive',
LANG: 'C.UTF-8',
TZ: 'UTC',
}, },
commands: [ commands: [
'[ -z "${DRONE_TAG}" ] && LDAP_VERSION=master || LDAP_VERSION="${DRONE_TAG%-*}"', 'make build',
'mkdir -p source/',
'rustup set profile minimal',
'curl -sSL https://github.com/ViViDboarder/bitwarden_rs_ldap/archive/"$$LDAP_VERSION".tar.gz | tar xz -C source/ --strip-components=1',
"grep -rlI 'Box<Error>' source/src/ | xargs sed -i 's/Box<Error>/Box<dyn Error>/g'",
'cd source/ && cargo build -j 8 --release',
], ],
}, },
{ {
name: 'dryrun', name: 'dryrun',
image: 'plugins/docker:' + tag, image: 'plugins/docker',
settings: { settings: {
dry_run: true, dry_run: true,
dockerfile: 'Dockerfile.' + arch, dockerfile: 'Dockerfile',
repo: 'xoxys/bitwardenrs_ldap', repo: 'xoxys/${DRONE_REPO_NAME}',
username: { from_secret: 'docker_username' }, username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' }, password: { from_secret: 'docker_password' },
}, },
@ -43,12 +34,12 @@ local PipelineBuild(arch='amd64') = {
}, },
{ {
name: 'publish', name: 'publish',
image: 'plugins/docker:' + tag, image: 'plugins/docker',
settings: { settings: {
auto_tag: true, auto_tag: true,
auto_tag_suffix: arch, auto_tag_suffix: arch,
dockerfile: 'Dockerfile.' + arch, dockerfile: 'Dockerfile',
repo: 'xoxys/bitwardenrs_ldap', repo: 'xoxys/${DRONE_REPO_NAME}',
username: { from_secret: 'docker_username' }, username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' }, password: { from_secret: 'docker_password' },
}, },
@ -112,7 +103,7 @@ local PipelineNotifications(depends_on=[]) = {
DOCKERHUB_USERNAME: { from_secret: 'docker_username' }, DOCKERHUB_USERNAME: { from_secret: 'docker_username' },
DOCKERHUB_PASSWORD: { from_secret: 'docker_password' }, DOCKERHUB_PASSWORD: { from_secret: 'docker_password' },
DOCKERHUB_REPO_PREFIX: 'xoxys', DOCKERHUB_REPO_PREFIX: 'xoxys',
DOCKERHUB_REPO_NAME: 'bitwardenrs_ldap', DOCKERHUB_REPO_NAME: '${DRONE_REPO_NAME}',
README_PATH: 'README.md', README_PATH: 'README.md',
SHORT_DESCRIPTION: 'Rootless Bitwarden_RS - Self-hosted password manager', SHORT_DESCRIPTION: 'Rootless Bitwarden_RS - Self-hosted password manager',
}, },

View File

@ -10,26 +10,18 @@ steps:
- name: binary - name: binary
image: clux/muslrust:nightly-2019-12-19 image: clux/muslrust:nightly-2019-12-19
commands: commands:
- "[ -z \"${DRONE_TAG}\" ] && LDAP_VERSION=master || LDAP_VERSION=\"${DRONE_TAG%-*}\"" - make build
- mkdir -p source/
- rustup set profile minimal
- curl -sSL https://github.com/ViViDboarder/bitwarden_rs_ldap/archive/"$$LDAP_VERSION".tar.gz | tar xz -C source/ --strip-components=1
- grep -rlI 'Box<Error>' source/src/ | xargs sed -i 's/Box<Error>/Box<dyn Error>/g'
- cd source/ && cargo build -j 8 --release
environment: environment:
DB: postgresql BUILD_VERSION: ${DRONE_TAG%-*}
DEBIAN_FRONTEND: noninteractive
LANG: C.UTF-8
TZ: UTC
- name: dryrun - name: dryrun
image: plugins/docker:linux-amd64 image: plugins/docker
settings: settings:
dockerfile: Dockerfile.amd64 dockerfile: Dockerfile
dry_run: true dry_run: true
password: password:
from_secret: docker_password from_secret: docker_password
repo: xoxys/bitwardenrs_ldap repo: xoxys/${DRONE_REPO_NAME}
username: username:
from_secret: docker_username from_secret: docker_username
when: when:
@ -37,14 +29,14 @@ steps:
- refs/pull/** - refs/pull/**
- name: publish - name: publish
image: plugins/docker:linux-amd64 image: plugins/docker
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 auto_tag_suffix: amd64
dockerfile: Dockerfile.amd64 dockerfile: Dockerfile
password: password:
from_secret: docker_password from_secret: docker_password
repo: xoxys/bitwardenrs_ldap repo: xoxys/${DRONE_REPO_NAME}
username: username:
from_secret: docker_username from_secret: docker_username
when: when:
@ -97,7 +89,7 @@ steps:
environment: environment:
DOCKERHUB_PASSWORD: DOCKERHUB_PASSWORD:
from_secret: docker_password from_secret: docker_password
DOCKERHUB_REPO_NAME: bitwardenrs_ldap DOCKERHUB_REPO_NAME: ${DRONE_REPO_NAME}
DOCKERHUB_REPO_PREFIX: xoxys DOCKERHUB_REPO_PREFIX: xoxys
DOCKERHUB_USERNAME: DOCKERHUB_USERNAME:
from_secret: docker_username from_secret: docker_username
@ -137,6 +129,6 @@ depends_on:
--- ---
kind: signature kind: signature
hmac: 25ce75557a40f6bc5b28e6cd1bfd8be018ccd81b72e9012da9bb04e7325f9330 hmac: 102f01aa01fda11f602b3287bcffaff10091321eb5f3ff83fe665090bd504297
... ...

27
Dockerfile Normal file
View File

@ -0,0 +1,27 @@
FROM xoxys/alpine
LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
org.label-schema.name="bitwardenrs_ldap" \
org.label-schema.vcs-url="https://gitea.rknet.org/docker/bitwardenrs_ldap" \
org.label-schema.vendor="Robert Kaussow" \
org.label-schema.schema-version="1.0"
ADD overlay/ /
RUN apk --update add ca-certificates && \
mkdir -p /app && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/* && \
chown -R app:app /app
ADD src/target/x86_64-unknown-linux-musl/release/bitwarden_rs_ldap /app
VOLUME /app/data
USER app
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/entrypoint"]
WORKDIR /app
CMD []

View File

@ -1,36 +0,0 @@
FROM alpine:3.11
LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
org.label-schema.name="bitwardenrs_ldap" \
org.label-schema.version="1.2" \
org.label-schema.vendor="Robert Kaussow" \
org.label-schema.schema-version="1.0"
RUN addgroup -g 101 -S app && \
adduser -S -D -H -u 101 -h /app -s /sbin/nologin -G app -g app app && \
apk --update add --virtual .build-deps tar curl && \
apk --update add ca-certificates && \
curl -SsL -o /usr/local/bin/gomplate https://github.com/hairyhenderson/gomplate/releases/download/v3.5.0/gomplate_linux-amd64-slim && \
curl -SsL -o /usr/local/bin/url-parser https://github.com/xoxys/url-parser/releases/download/v0.1.0/url-parser-0.1.0-linux-amd64 && \
curl -SsL -o /usr/local/bin/wait-for https://raw.githubusercontent.com/xoxys/wait-for/master/wait-for && \
chmod 755 /usr/local/bin/gomplate && \
chmod 755 /usr/local/bin/url-parser && \
chmod 755 /usr/local/bin/wait-for && \
apk del .build-deps && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/* && \
mkdir -p /app && \
chown -R app:app /app
ADD overlay/ /
ADD source/target/x86_64-unknown-linux-musl/release/bitwarden_rs_ldap /app
VOLUME /app/data
USER app
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/entrypoint"]
WORKDIR /app
CMD []

26
Makefile Normal file
View File

@ -0,0 +1,26 @@
export BUILD_VERSION ?= master
export DEBIAN_FRONTEND ?= noninteractive
export LANG ?= C.UTF-8
export TZ ?= UTC
SRC := src
.PHONY: all
all: build
.PHONY: build
build: build-src build-bin
.PHONY: build-src
build-src:
mkdir -p $(SRC); \
curl -sSL "https://github.com/ViViDboarder/bitwarden_rs_ldap/archive/$${BUILD_VERSION}.tar.gz" | tar xz -C $(SRC) --strip-components=1
.PHONY: build-bin
build-bin:
rustup set profile minimal && \
cd $(SRC) && \
cargo build -j 8 --release
.PHONY: clean
clean:
rm -rf $(SRC)

View File

@ -1,4 +1,4 @@
# [bitwarden_rs_ldap](https://gitea.rknet.org/docker/bitwarden_rs_ldap) # [bitwardenrs_ldap](https://gitea.rknet.org/docker/bitwarden_rs_ldap)
[![Build Status](https://img.shields.io/drone/build/docker/bitwarden_rs_ldap?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/docker/bitwarden_rs_ldap) [![Build Status](https://img.shields.io/drone/build/docker/bitwarden_rs_ldap?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/docker/bitwarden_rs_ldap)
[![Docker Hub](https://img.shields.io/badge/docker-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/xoxys/bitwardenrs_ldap) [![Docker Hub](https://img.shields.io/badge/docker-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/xoxys/bitwardenrs_ldap)