From 55f025bd35b710ea708a1c338565195b6e442ed5 Mon Sep 17 00:00:00 2001 From: Varakh Date: Sat, 25 Mar 2023 09:07:43 +0100 Subject: [PATCH] Add automatic build for docker images and publish to dockerhub with drone --- .drone.yml | 71 ++++++++++++++++++++++++ .gitignore | 1 + Dockerfile | 109 ++++++++++++++++++------------------- README.md | 4 +- build.sh => local_build.sh | 2 +- 5 files changed, 130 insertions(+), 57 deletions(-) create mode 100644 .drone.yml rename build.sh => local_build.sh (96%) diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..1b90a56 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,71 @@ +--- +kind: pipeline +type: docker +name: default + +trigger: + event: + include: + - push + - cron + branch: + - master + +environment: &default_environment + REVISION: ${DRONE_COMMIT_SHA} + CREATED: ${DRONE_BUILD_CREATED} + SOURCE_URL: ${DRONE_GIT_HTTP_URL} + # also change in 'tags' of build docker + FB_VERSION: 4.0.0 + BUILD_DIR: /drone/src/fb_src + +steps: + - name: prepare environment and build clone file bin + image: alpine + commands: + - apk update + - apk add git bash + - bash -c "[[ -d $BUILD_DIR ]] && rm -rf $BUILD_DIR || echo 'Nothing to clean'" + - git config --global advice.detachedHead false + - git clone --branch $FB_VERSION https://github.com/Bluewind/filebin --depth=1 $BUILD_DIR + - rm -rf $BUILD_DIR/.git + + - name: build docker image + image: plugins/docker + environment: + <<: *default_environment + settings: + purge: true + repo: varakh/filebin + tags: + - latest + - 4.0.0 + + - name: notify + image: drillster/drone-email + settings: + subject: "Build failed" + body: "URL ${DRONE_BUILD_LINK}" + host: + from_secret: mail_host + username: + from_secret: mail_user + password: + from_secret: mail_password + from: + from_secret: mail_from + when: + status: + - failure + + - name: clean up + image: alpine + commands: + - apk update + - apk add bash + - bash -c "[[ -d $BUILD_DIR ]] && rm -rf $BUILD_DIR || echo 'Nothing to clean'" +--- +kind: signature +hmac: 220cafe5d49c70697787b6cd29a4efbfb6b5d72162aefb3becf59285c3809bb7 + +... diff --git a/.gitignore b/.gitignore index a83bb87..8a05aa3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build/ .idea/ +fb_src/ diff --git a/Dockerfile b/Dockerfile index 7b4df3b..9837580 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,63 +1,62 @@ FROM alpine:3 -LABEL maintainer="Varakh" +LABEL maintainer="Varakh " \ + description="filebin" \ + org.opencontainers.image.authors="Varakh" \ + org.opencontainers.image.revision="${REVISION}" \ + org.opencontainers.image.vendor="Varakh" \ + org.opencontainers.image.title="filebin" \ + org.opencontainers.image.description="filebin" \ + org.opencontainers.image.base.name="alpine:3" \ + org.opencontainers.artifact.created=${CREATED} \ + org.opencontainers.image.source=${SOURCE_URL} -# Expose variables to ease overwriting -ENV RECONFIGURE true -ENV MIGRATE true +ENV RECONFIGURE=true \ + MIGRATE=true \ + PHP_MEMORY_LIMIT=512M \ + MAX_UPLOAD=1024M \ + PHP_MAX_FILE_UPLOAD=100 \ + PHP_MAX_POST=1024M \ + DB_DSN='' \ + DB_HOST=localhost \ + DB_PORT=5432 \ + DB_DRIVER=postgre \ + DB_NAME=fb \ + DB_USER=fb \ + DB_PASS=fb \ + DB_PREFIX='' \ + DB_PCONNECT='0' \ + DB_DEBUG='1' \ + DB_CHAR_SET=utf8 \ + DB_COLLAT=utf8_bin \ + DB_SWAP_PRE='' \ + DB_ENCRYPT='0' \ + DB_COMPRESS='0' \ + DB_STRICTON='0' \ + DB_SAVE_QUERIES='0' \ + BASE_URL='' \ + INDEX_PAGE='' \ + ENCRYPTION_KEY='' \ + CACHE_BACKEND=dummy \ + EMAIL_FROM='' \ + UPLOAD_MAX_SIZE=1073741824 \ + UPLOAD_MAX_TEXT_SIZE=2097152 \ + UPLOAD_MAX_AGE=432000 \ + ACTIONS_MAX_AGE=86400 \ + SMALL_UPLOAD_SIZE=5120 \ + TARBALL_MAX_SIZE=1073741824 \ + TARBALL_CACHE_TIME=300 \ + MAX_INVITATION_KEYS=3 \ + SMTP_ENABLED=false \ + SMTP_PROTOCOL='smtp' \ + SMTP_HOST='' \ + SMTP_PORT=587 \ + SMTP_CRYPTO='tls' \ + SMTP_USER='' \ + SMTP_PASS='' -# php.ini -ENV PHP_MEMORY_LIMIT 512M -ENV MAX_UPLOAD 1024M -ENV PHP_MAX_FILE_UPLOAD 100 -ENV PHP_MAX_POST 1024M - -# database.php -ENV DB_DSN '' -ENV DB_HOST localhost -ENV DB_PORT 5432 -ENV DB_DRIVER postgre -ENV DB_NAME fb -ENV DB_USER fb -ENV DB_PASS fb -ENV DB_PREFIX '' -ENV DB_PCONNECT '0' -ENV DB_DEBUG '1' -ENV DB_CHAR_SET utf8 -ENV DB_COLLAT utf8_bin -ENV DB_SWAP_PRE '' -ENV DB_ENCRYPT '0' -ENV DB_COMPRESS '0' -ENV DB_STRICTON '0' -ENV DB_SAVE_QUERIES '0' - -# config-local.php -ENV BASE_URL '' -ENV INDEX_PAGE '' -ENV ENCRYPTION_KEY '' -ENV CACHE_BACKEND dummy -ENV EMAIL_FROM '' -ENV UPLOAD_MAX_SIZE 1073741824 -ENV UPLOAD_MAX_TEXT_SIZE 2097152 -ENV UPLOAD_MAX_AGE 432000 -ENV ACTIONS_MAX_AGE 86400 -ENV SMALL_UPLOAD_SIZE 5120 -ENV TARBALL_MAX_SIZE 1073741824 -ENV TARBALL_CACHE_TIME 300 -ENV MAX_INVITATION_KEYS 3 -ENV SMTP_ENABLED false -ENV SMTP_PROTOCOL 'smtp' -ENV SMTP_HOST '' -ENV SMTP_PORT 587 -ENV SMTP_CRYPTO 'tls' -ENV SMTP_USER '' -ENV SMTP_PASS '' - -# add script for database ADD src/wait-for.sh /wait-for.sh - -# add upstream application -ADD build/ /var/www +ADD fb_src/ /var/www # install dependencies RUN chmod -x /wait-for.sh && \ diff --git a/README.md b/README.md index 724121a..000267d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # FileBin 🐋 +[![Build Status](https://drone.myservermanager.com/api/badges/varakh/docker-filebin/status.svg)](https://drone.myservermanager.com/varakh/docker-filebin) + A docker image for [FileBin](https://git.server-speed.net/users/flo/filebin/) to have it up and running in seconds. Visit project on [https://git.myservermanager.com/varakh/docker-filebin](https://git.myservermanager.com/varakh/docker-filebin) @@ -158,4 +160,4 @@ Steps: * Build image * Push to registry or use locally -Call `build.sh` and export `FB_VERSION=$versionTag` before, e.g. `FB_VERSION=3.6.2`. +Call `local_build.sh` and export `FB_VERSION=$versionTag` before, e.g. `FB_VERSION=3.6.2`. diff --git a/build.sh b/local_build.sh similarity index 96% rename from build.sh rename to local_build.sh index cb7f12d..ddc5221 100755 --- a/build.sh +++ b/local_build.sh @@ -9,7 +9,7 @@ else exit 1; fi -BUILD_DIR="build" +BUILD_DIR="fb_src" if [[ ! -d "${BUILD_DIR}" ]]; then mkdir -p "${BUILD_DIR}";