Browse Source

Fix drone workflow

- Drone builds actually work w/ docker runner now
- Versions are tagged with major, minor, and z releases. Non-main tags are appended with "-dev"
- No reliance on build.sh at all
- Reduce number of generated locales to improve build times

Co-authored-by: James Harmison <jharmison@gmail.com>
Reviewed-on: #1
Co-Authored-By: James Harmison <jharmison@noreply.git.jharmison.com>
Co-Committed-By: James Harmison <jharmison@noreply.git.jharmison.com>
enhancement/kaniko
James Harmison 2 months ago
parent
commit
1b854ccfff
2 changed files with 56 additions and 37 deletions
  1. +41
    -21
      .drone.yml
  2. +15
    -16
      Dockerfile

+ 41
- 21
.drone.yml View File

@ -4,30 +4,50 @@ type: docker
name: build
steps:
- name: prep
image: alpine
commands:
- apk add jq curl
# Create tags for Akaunting release versions
# e.g. images that include 2.0.26 will be tagged with 2, 2.0, and 2.0.26
- >
curl -s https://api.github.com/repos/akaunting/akaunting/releases/latest
| jq -r .tag_name | sed 's/\(\(\([0-9]\+\)\.[0-9]\+\)\.[0-9]\+\)/\1,\2,\3/'
> .tags
# For all non-main pushes, append tags with "-dev"
- >
[ "${DRONE_COMMIT_BRANCH}" == "main" -a -n "${DRONE_PULL_REQUEST}" ]
|| sed -i -e "s/\([0-9]\+\)\([^0-9.]\)/\1-dev\2/g" -e "s/$/-dev,dev/" .tags
# Helpful debug output
- cat .tags
- name: docker
image: docker
image: plugins/docker
privileged: true
volumes:
- name: docker_sock
path: /var/run/docker.sock
commands:
# git, jq, and curl for pulling information to tag and label the image with
- apk add git jq curl
# login to the registry from secrets
- docker login -u $REGISTRY_USER -p $REGISTRY_PASSWORD $REGISTRY
# always push, configure registry just in case
- build_args=(-p -r $REGISTRY)
# only push latest on main, on all others add a dev suffix
- if [ "$DRONE_COMMIT_BRANCH" == "main" ]; then build_args+=(-t latest); else build_args+=(-d)'; fi
# grab the akaunting release version we expect to download
- export akaunting_release=$(curl -s https://api.github.com/repos/akaunting/akaunting/releases/latest | jq -r ".tag_name")
- export akaunting_release_short=$(echo "$akaunting_release" | cut -d. -f1)
# tag image with akaunting release
- build_args+=(-t $akaunting_release -t $akaunting_release_short)
# build and push arccording to built args
- ./build.sh "${build_args[@]}"
environment:
REGISTRY: harbor.jharmison.com
REGISTRY_USER:
settings:
username:
from_secret: HARBOR_USER
REGISTRY_PASSWORD:
password:
from_secret: HARBOR_PASSWORD
repo: harbor.jharmison.com/akaunting/akaunting
registry: harbor.jharmison.com
pull_image: true
purge: false
build_args:
- GIT_BRANCH=${DRONE_COMMIT_BRANCH}
- GIT_COMMIT=${DRONE_COMMIT}
- SUPPORTED_LOCALES="en_US.UTF-8"
volumes:
- name: docker_sock
host:
path: /var/run/docker.sock
---
kind: signature
hmac: 45efdabf7a4c53f67199e56680e506c021fd7a82421991c1c24eb8d1f2b56188
...

+ 15
- 16
Dockerfile View File

@ -1,5 +1,16 @@
FROM php:7.4-apache
ARG AKAUNTING_DOCKERFILE_VERSION=0.1
ARG GIT_BRANCH=undefined
ARG GIT_COMMIT=undefined
ARG SUPPORTED_LOCALES="en_US.UTF-8"
LABEL maintainer="James Harmison <jharmison@gmail.com>" \
com.jharmison.akaunting.dockerfile.version=$AKAUNTING_DOCKERFILE_VERSION \
com.jharmison.akaunting.branch=$GIT_BRANCH \
com.jharmison.akaunting.commit=$GIT_COMMIT \
com.jharmison.akaunting.locales="$SUPPORTED_LOCALES"
RUN apt-get update \
&& apt-get -y upgrade --no-install-recommends \
&& apt-get install -y \
@ -23,8 +34,10 @@ RUN apt-get update \
zip \
zlib1g-dev \
--no-install-recommends \
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
&& cp /usr/share/i18n/SUPPORTED /etc/locale.gen \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN for locale in ${SUPPORTED_LOCALES}; do \
sed -i 's/^# '"${locale}/${locale}/" /etc/locale.gen; done \
&& locale-gen
RUN docker-php-ext-configure gd \
@ -45,22 +58,8 @@ RUN mkdir -p /var/www/akaunting \
&& unzip /tmp/akaunting.zip -d /var/www/html \
&& rm -f /tmp/akaunting.zip
ARG AKAUNTING_DOCKERFILE_VERSION=0.1
ARG GIT_BRANCH=undefined
ARG GIT_COMMIT=undefined
ARG BUILD_DATE=undefined
LABEL maintainer="James Harmison <jharmison@gmail.com>" \
com.jharmison.akaunting.dockerfile.version=$AKAUNTING_DOCKERFILE_VERSION \
com.jharmison.akaunting.branch=$GIT_BRANCH \
com.jharmison.akaunting.commit=$GIT_COMMIT \
com.jharmison.akaunting.build-date=$BUILD_DATE
COPY files/akaunting.sh /usr/local/bin/akaunting.sh
COPY files/html /var/www/html
EXPOSE 80
ENTRYPOINT ["/usr/local/bin/akaunting.sh"]
CMD ["--start"]

Loading…
Cancel
Save