Browse Source

build deb and tar.gz in docker container, amzn tar.gz in another container

pull/1/head
Benedikt Kristinsson 7 months ago
parent
commit
e1bd6cd84d
9 changed files with 153 additions and 115 deletions
  1. +4
    -0
      .dockerignore
  2. +4
    -1
      .gitignore
  3. +102
    -5
      Jenkinsfile
  4. +9
    -3
      README.md
  5. +11
    -8
      amzn/Dockerfile
  6. +1
    -12
      amzn/package.sh
  7. +19
    -12
      debian/Dockerfile
  8. +3
    -6
      debian/package.sh
  9. +0
    -68
      jenkins.sh

+ 4
- 0
.dockerignore View File

@ -0,0 +1,4 @@
**/.git
.gitignore
.gitattributes
.gitlab-ci.yml

+ 4
- 1
.gitignore View File

@ -1,3 +1,6 @@
dist/
emacs/
*.tar.xz
emacs-src/
*.tar.xz
\#*
.\#*

+ 102
- 5
Jenkinsfile View File

@ -1,21 +1,118 @@
def version = ""
def amzn_prefix = "/home/bkristinsson/.local"
pipeline {
agent any
options {
timestamps()
ansiColor("xterm")
disableConcurrentBuilds()
skipDefaultCheckout()
}
stages {
stage('amzn') {
steps {
sh './jenkins.sh amzn'
stage('checkout') {
steps{
checkout scm
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
extensions: [[
$class: 'RelativeTargetDirectory',
relativeTargetDir: 'emacs-src'
]],
doGenerateSubmoduleConfigurations: false,
// extensions: [[$class: 'CloneOption',
// depth: 1, noTags: false, shallow: true]],
userRemoteConfigs: [[
url: 'https://git.sudo.is/mirrors/emacs.git'
]],
//branches: [[name: "refs/tags/emacs-${env.VERSION}"]]
branches: [[name: "master"]]
])
dir('emacs-src') {
script {
// current branch should be 'master'
sh "git --no-pager show --oneline -s"
// in master branch,
// git describe --tags --abbrev=0
// emacs-27.1
//
// in emacs-27 branch:
// git describe --tags --abbrev=0
// emacs-27.1.91
//
def latest_tag = sh(
script: 'git describe --tags --abbrev=0',
returnStdout: true
)
echo latest_tag
// the latest tag that is reachable from master
// seems to be the latest stable release.
//
// to get the latest minor relase instead,
// check out the emacs-$MAJOR branch (not tag)
version = latest_tag.split('-')[1].trim()
sh "git checkout refs/tags/${latest_tag}"
sh "git --no-pager show --oneline -s"
}
}
}
}
stage('debian') {
stage ('deb: build emacs') {
steps {
sh './jenkins.sh debian'
sh "docker build -f debian/Dockerfile --build-arg PREFIX=/emacs/target --build-arg VERSION=${version} --target builder -t benediktkr/emacs:builder-${version} ."
sh "docker container create --name emacs_debian_builder benediktkr/emacs:builder-${version}"
dir('dist/') {
sh "docker container cp emacs_debian_builder:/emacs/debian/ ."
}
}
}
stage('deb: container') {
steps {
sh "docker build -f debian/Dockerfile -t benediktkr/emacs:${version} ."
}
}
stage('deb: dockerhub') {
steps {
sh "docker push benediktkr/emacs:${version}"
}
}
stage('amzn') {
steps {
sh "docker build -f amzn/Dockerfile --build-arg PREFIX=${amzn_prefix} --build-arg VERSION=${version} -t emacs-amzn:${version}-amzn ."
sh "docker container create --name emacs_amzn_builder emacs-amzn:${version}-amzn "
sh "docker container cp emacs_amzn_builder:/emacs/amzn/ dist/"
}
}
}
post {
success {
archiveArtifacts(
artifacts: 'dist/*/*.tar.gz,dist/*/*.deb',
fingerprint: true
)
}
cleanup {
sh "docker container rm emacs_debian_builder || true"
sh "docker container rm emacs_amzn_builder || true"
}
// always {
// cleanWs(
// deleteDirs: true,
// patterns: [[pattern: 'emacs-src', type: 'EXCLUDE']],
// disableDeferredWipeout: true,
// notFailBuild: true
// )
// }
}
}

+ 9
- 3
README.md View File

@ -1,9 +1,15 @@
# emacs-docker
[![Build Status](https://jenkins.sudo.is/buildStatus/icon?job=ben%2Femacs-docker%2Fmaster&style=flat-square)](https://jenkins.sudo.is/job/ben/job/emacs-docker/job/master/)
![Docker Image Version (latest by date)](https://img.shields.io/docker/v/benediktkr/emacs?style=flat-square)
![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/benediktkr/emacs?sort=date&style=flat-square)
Currently no build system behind this. Images are manually maintained at [hub.docker.com/r/benediktkr/emacs-docker](https://hub.docker.com/r/benediktkr/emacs-docker/).
Builds the latest stable emacs in a docker image, packages it as `.deb` and `.tar.gz` and then publishe a [docker image to Docker Hub](https://hub.docker.com/r/benediktkr/emacs-docker/) with emacs installed.
The `Dockerfile` in `git/` will use an Ubuntu-based image to build the latest version of Emacs from git.
Currently the `.deb` package has no dependencies and there isn't an apt archive hosting it either.
The `Dockerfile` in `alpine/` uses an alpine-based image to run the latest alpine-provided version of Emacs, since they are up-to-date with stable. The `latest` tag points to this version.
Dockerfiles for other docker images:
* `git/Dockerfile`: clone the emacs repo with git and build emacs.
* `amzn/Dockerfile`: custom Amazon Linux 1 docker build
* `alpine/Dockerfile`: alpine has up-to-date emacs versions.

+ 11
- 8
amzn/Dockerfile View File

@ -8,19 +8,22 @@ RUN yum -y update && \
yum -y install devtoolset-9-gcc devtoolset-9-libgccjit-devel gnutls-devel git ncurses-devel && \
yum -y groupinstall "Development Tools"
ADD emacs-${VERSION}.tar.xz /emacs
ADD emacs-src/ /emacs/emacs-${VERSION}
WORKDIR /emacs/emacs-${VERSION}
RUN ./configure --prefix=${PREFIX} --with-x=no CFLAGS="-I$ORIGIN/../include" --without-sound \
LDFLAGS="-L$ORIGIN/lib -Wl,-rpath=\\\$\$ORIGIN/../lib"
RUN ./autogen.sh && \
./configure --prefix=${PREFIX} --with-x=no CFLAGS="-I$ORIGIN/../include" --without-sound LDFLAGS="-L$ORIGIN/lib -Wl,-rpath=\\\$\$ORIGIN/../lib"
RUN make -j${CPU_COUNT}
RUN make install -j${CPU_COUNT}
ADD entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
ENV VERSION ${VERSION}
ENV PREFIX ${PREFIX}
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["package"]
ADD amzn/package.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/package.sh
RUN /usr/local/bin/package.sh
RUN rm -rf /emacs/emacs-${VERSION}
RUN ${PREFIX}/bin/emacs --version
CMD ["${PREFIX}/bin/emacs"]

amzn/entrypoint.sh → amzn/package.sh View File


+ 19
- 12
debian/Dockerfile View File

@ -1,12 +1,12 @@
FROM debian:bullseye
FROM debian:bullseye as base
ARG VERSION=27.1
ARG CPU_COUNT=8
ARG PREFIX=/emacs/target
ENV VERSION ${VERSION}
ENV PREFIX ${PREFIX}
ENV DEBIAN_FRONTEND noninteractive
ENV VERSION=${VERSION}
ENV PREFIX=${PREFIX}
ENV DEBIAN_FRONTEND=noninteractive
RUN mkdir -p /emacs/target && \
apt-get update && \
@ -15,17 +15,24 @@ RUN mkdir -p /emacs/target && \
ruby ruby-dev rubygems build-essential git && \
gem install --no-document fpm
# untars !
ADD emacs-${VERSION}.tar.xz /emacs
FROM base as builder
ADD emacs-src/ /emacs/emacs-${VERSION}
WORKDIR /emacs/emacs-${VERSION}
RUN ./configure --prefix=$PREFIX --with-x=no CFLAGS="-I$ORIGIN/include" \
LDFLAGS="-L$ORIGIN/lib -Wl,-rpath=\\\$\$ORIGIN/../lib"
RUN ./autogen.sh \
&& ./configure --prefix=$PREFIX --with-x=no CFLAGS="-I$ORIGIN/include" LDFLAGS="-L$ORIGIN/lib -Wl,-rpath=\\\$\$ORIGIN/../lib"
RUN make -j${CPU_COUNT}
RUN make install -j${CPU_COUNT}
ADD entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ADD debian/package.sh /usr/local/bin/package.sh
RUN chmod +x /usr/local/bin/package.sh
RUN /usr/local/bin/package.sh
RUN rm -rf /emacs/emacs-${VERSION}
FROM builder as final
RUN dpkg -i /emacs/debian/emacs_27.1_amd64.deb \
&& rm -rf /emacs/debian
RUN /usr/bin/emacs --version
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["package"]
CMD ["/usr/bin/emacs"]

debian/entrypoint.sh → debian/package.sh View File


+ 0
- 68
jenkins.sh View File

@ -1,68 +0,0 @@
#!/bin/bash
set -x
set -e
build_debian() {
cp emacs-${VERSION}.tar.xz debian/
PREFIX=/emacs/target
docker build --build-arg PREFIX=$PREFIX --build-arg VERSION=$VERSION -t emacs-debian debian/
# debian tags:
# * :debian
# * :27.1
# * :27.1-debian
docker tag emacs-debian benediktkr/emacs:debian
docker tag emacs-debian benediktkr/emacs:${VERSION}
docker tag emacs-debian benediktkr/emacs:${VERSION}-debian
docker rm emacs-debian-package || true
docker run --name emacs-debian-package emacs-debian
docker cp emacs-debian-package:/emacs/debian dist/
docker rm emacs-debian-package
}
build_amzn () {
cp emacs-${VERSION}.tar.xz amzn/
PREFIX=/home/bkristinsson/.local
docker build --build-arg PREFIX=$PREFIX --build-arg VERSION=$VERSION -t emacs-amzn amzn/
# amzn tags:
# * :amzn
# * :27.1-amzn
docker tag emacs-amzn benediktkr/emacs:amzn
docker tag emacs-amzn benediktkr/emacs:${VERSION}-amzn
docker rm emacs-amzn-package || true
docker run --name emacs-amzn-package emacs-amzn
docker cp emacs-amzn-package:/emacs/amzn dist/
docker rm emacs-amzn-package
}
VERSION="27.1"
COPYTO="$(pwd)/dist"
mkdir -p $COPYTO
env
if [ ! -f emacs-${VERSION}.tar.xz ]; then
wget -q https://ftp.gnu.org/pub/gnu/emacs/emacs-${VERSION}.tar.xz
fi
if [ "$1" = "debian" ]; then
build_debian
fi
if [ "$1" = "amzn" ]; then
build_amzn
fi

Loading…
Cancel
Save