refactoring
Some checks are pending
continuous-integration/drone/push Build is pending

This commit is contained in:
Robert Kaussow 2020-02-22 16:58:35 +01:00
parent 795fe57ff4
commit ef345d6ae9
6 changed files with 85 additions and 84 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,20 @@ 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}" ] && BITWARDEN_VERSION=1.13.1 || BITWARDEN_VERSION="${DRONE_TAG##v}"',
'mkdir -p source/',
'apt-get -qq update && apt-get install -yqq --no-install-recommends libpq-dev', 'apt-get -qq update && apt-get install -yqq --no-install-recommends libpq-dev',
'rustup set profile minimal', 'make build',
'curl -sSL https://github.com/dani-garcia/bitwarden_rs/archive/"$${BITWARDEN_VERSION%-*}".tar.gz | tar xz -C source/ --strip-components=1',
'cd source/ && cargo build -j 8 --features $DB --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', 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 +35,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', 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 +104,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', 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,19 @@ steps:
- name: binary - name: binary
image: clux/muslrust:nightly-2019-12-19 image: clux/muslrust:nightly-2019-12-19
commands: commands:
- "[ -z \"${DRONE_TAG}\" ] && BITWARDEN_VERSION=1.13.1 || BITWARDEN_VERSION=\"${DRONE_TAG##v}\""
- mkdir -p source/
- "apt-get -qq update && apt-get install -yqq --no-install-recommends libpq-dev " - "apt-get -qq update && apt-get install -yqq --no-install-recommends libpq-dev "
- rustup set profile minimal - make build
- curl -sSL https://github.com/dani-garcia/bitwarden_rs/archive/"$${BITWARDEN_VERSION%-*}".tar.gz | tar xz -C source/ --strip-components=1
- cd source/ && cargo build -j 8 --features $DB --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 repo: xoxys/${DRONE_REPO_NAME}
username: username:
from_secret: docker_username from_secret: docker_username
when: when:
@ -37,14 +30,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 repo: xoxys/${DRONE_REPO_NAME}
username: username:
from_secret: docker_username from_secret: docker_username
when: when:
@ -97,7 +90,7 @@ steps:
environment: environment:
DOCKERHUB_PASSWORD: DOCKERHUB_PASSWORD:
from_secret: docker_password from_secret: docker_password
DOCKERHUB_REPO_NAME: bitwardenrs 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
@ -135,8 +128,4 @@ trigger:
depends_on: depends_on:
- build-container-amd64 - build-container-amd64
---
kind: signature
hmac: 5164600e992db4b554b23132b90d2d9ec998b86b161250a12c06a34896b4fccb
... ...

38
Dockerfile Normal file
View File

@ -0,0 +1,38 @@
FROM xoxys/alpine:3.11
LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
org.label-schema.name="bitwardenrs" \
org.label-schema.version="1.2" \
org.label-schema.vendor="Robert Kaussow" \
org.label-schema.schema-version="1.0"
ARG VAULT_VERSION=2.12.0c
ADD overlay/ /
RUN apk --update add --virtual .build-deps tar curl && \
apk --update add openssl postgresql-libs ca-certificates && \
mkdir -p /app/web-vault /app/data && \
curl -SsL "https://github.com/dani-garcia/bw_web_builds/releases/download/v${VAULT_VERSION}/bw_web_v${VAULT_VERSION}.tar.gz" | \
tar xz -C /app/web-vault && \
apk del .build-deps && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/* && \
chown -R app:app /app
ADD src/Rocket.toml /app
ADD src/target/x86_64-unknown-linux-musl/release/bitwarden_rs /app
VOLUME /app/data
EXPOSE 8080
EXPOSE 3012
USER app
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/entrypoint"]
HEALTHCHECK --interval=10s --timeout=3s --retries=3 CMD /usr/local/bin/healthcheck
WORKDIR /app
CMD []

View File

@ -1,45 +0,0 @@
FROM alpine:3.11
LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
org.label-schema.name="bitwardenrs" \
org.label-schema.version="1.2" \
org.label-schema.vendor="Robert Kaussow" \
org.label-schema.schema-version="1.0"
ARG VAULT_VERSION=2.12.0c
ARG VAULT_TARBALL=https://github.com/dani-garcia/bw_web_builds/releases/download/v${VAULT_VERSION}/bw_web_v${VAULT_VERSION}.tar.gz
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 openssl postgresql-libs 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 && \
mkdir -p /app/web-vault /app/data && \
curl -SsL ${VAULT_TARBALL} | tar xz -C /app/web-vault && \
apk del .build-deps && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/* && \
chown -R app:app /app
ADD overlay/ /
ADD source/Rocket.toml /app
ADD source/target/x86_64-unknown-linux-musl/release/bitwarden_rs /app
VOLUME /app/data
EXPOSE 8080
EXPOSE 3012
USER app
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/entrypoint"]
HEALTHCHECK --interval=10s --timeout=3s --retries=3 CMD /usr/local/bin/healthcheck
WORKDIR /app
CMD []

27
Makefile Normal file
View File

@ -0,0 +1,27 @@
BUILD_VERSION ?= 1.13.1
DB ?= postgresql
DEBIAN_FRONTEND ?= noninteractive
LANG ?= C.UTF-8
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/dani-garcia/bitwarden_rs/archive/$${BUILD_VERSION##v}.tar.gz" | tar xz -C $(SRC) --strip-components=1
.PHONY: build-bin
build-bin:
rustup set profile minimal && \
cd $(SRC) && \
cargo build -j 8 --features $(DB) --release
.PHONY: clean
clean:
rm -rf $(SRC)

View File

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