-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-ubuntu-22.04
63 lines (54 loc) · 2.24 KB
/
Dockerfile-ubuntu-22.04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
FROM ubuntu:24.04
ARG PKG_NAME
ARG PKG_VERSION
ARG PKG_RELEASE
ARG PKG_ARCH
ARG PKG_MAINTAINER
ARG PKG_DOWNLOAD
ARG BUILD_DIR
# Install necessary packages
RUN apt-get update && \
apt-get install -y dpkg-dev debhelper wget
# Prepare environment
RUN mkdir -p $BUILD_DIR/src \
$BUILD_DIR/deb \
$BUILD_DIR/build/DEBIAN \
$BUILD_DIR/build/usr/bin \
$BUILD_DIR/build/etc/logrotate.d/ \
$BUILD_DIR/build/etc/systemd/system \
$BUILD_DIR/build/etc/traefik \
$BUILD_DIR/build/etc/traefik/conf.d \
$BUILD_DIR/build/var/log/traefik \
$BUILD_DIR/build/usr/share/doc/traefik
# Set file permissions and copy configurations
COPY files/all/postinst $BUILD_DIR/build/DEBIAN/
COPY files/all/postrm $BUILD_DIR/build/DEBIAN/
COPY files/all/control $BUILD_DIR/build/DEBIAN/control
COPY files/all/systemd.conf $BUILD_DIR/build/etc/systemd/system/traefik.service
COPY files/all/traefik.yml $BUILD_DIR/build/etc/traefik/
COPY files/all/default.yml $BUILD_DIR/build/etc/traefik/conf.d/
COPY files/all/logrotate.conf $BUILD_DIR/build/etc/logrotate.d/traefik
RUN chmod +x $BUILD_DIR/build/DEBIAN/postinst
RUN chmod +x $BUILD_DIR/build/DEBIAN/postrm
RUN touch $BUILD_DIR/build/etc/traefik/acme.json
RUN chmod 0600 $BUILD_DIR/build/etc/traefik/acme.json
RUN chmod 0750 $BUILD_DIR/build/var/log/traefik
# Download and prepare the source
RUN wget -c $PKG_DOWNLOAD -O $BUILD_DIR/src/traefik.tar.gz
RUN tar -zxvf $BUILD_DIR/src/traefik.tar.gz -C $BUILD_DIR/src/
RUN cp $BUILD_DIR/src/traefik $BUILD_DIR/build/usr/bin/
RUN cp $BUILD_DIR/src/LICENSE.md $BUILD_DIR/build/usr/share/doc/traefik/
RUN gzip -f $BUILD_DIR/src/CHANGELOG.md
RUN cp $BUILD_DIR/src/CHANGELOG.md.gz $BUILD_DIR/build/usr/share/doc/traefik/
# Template adjustments with sed
RUN sed -i \
-e "s|__PKG_NAME__|${PKG_NAME}|g" \
-e "s|__PKG_VERSION__|${PKG_VERSION}-${PKG_RELEASE}|g" \
-e "s|__PKG_ARCH__|${PKG_ARCH}|g" \
-e "s|__PKG_MAINTAINER__|${PKG_MAINTAINER}|g" \
$BUILD_DIR/build/DEBIAN/control
RUN chown root:root -R $BUILD_DIR/build
RUN chown www-data:adm -R $BUILD_DIR/build/var/log/traefik
RUN chown www-data:adm -R $BUILD_DIR/build/etc/traefik/acme.json
# Build image
RUN dpkg-deb --build $BUILD_DIR/build $BUILD_DIR/deb/${PKG_NAME}_${PKG_VERSION}-${PKG_RELEASE}_${PKG_ARCH}.deb