-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
166 lines (141 loc) · 6.28 KB
/
Dockerfile
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
###################################
# REQUIRED for bashLaVa https://github.com/firepress-org/bashlava
# REQUIRED for Github Action CI template https://github.com/firepress-org/ghostfire/tree/master/.github/workflows
###################################
ARG APP_NAME="resilio"
ARG VERSION="2.7.2"
ARG RELEASE="2.7.2"
ARG GITHUB_USER="firepress-org"
###################################
# REQUIRED BY OUR GITHUB ACTION CI
###################################
ARG GIT_PROJECT_NAME="ghostfire"
ARG DOCKERHUB_USER="devmtl"
ARG GITHUB_ORG="firepress-org"
ARG GITHUB_REGISTRY="registry"
ARG GIT_REPO_DOCKERFILE="https://github.com/firepress-org/resilio-in-docker"
ARG GIT_REPO_SOURCE="https://github.com/bt-sync/sync-docker/blob/master/Dockerfile"
###################################
# Start you Dockerfile from here
###################################
ARG ALPINE_VERSION="3.12"
ARG USER="root"
ARG BINARY_NAME="rslsync"
ARG GLIBC_VERSION="2.32-r0"
ARG ALPINE_GLIBC="alpine-glibc"
ARG ALPINE_BASE="alpine-base"
# GNU v3 | Please credit my work if you are re-using some of it :)
# by Pascal Andy | https://pascalandy.com/blog/now/
# https://help.resilio.com/hc/en-us/articles/206216855-Sync-2-x-change-log
# https://github.com/sgerrand/alpine-pkg-glibc"
# ----------------------------------------------
# base LAYER
# credits: https://github.com/nimmis/docker-alpine-micro
# ----------------------------------------------
FROM alpine:${ALPINE_VERSION} AS alpinebase
RUN set -eux && echo "@community http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
# read packages and update
apk update && apk upgrade && \
# add packages
apk add --no-cache ca-certificates rsyslog logrotate runit && \
# Make info file about this build
mkdir -p /etc/BUILDS/ && \
# install extra from github, including replacement for process 0 (init)
# add extra package for installation
apk add curl && \
cd /tmp && \
# Install utils and init process
curl -Ls https://github.com/nimmis/docker-utils/archive/master.tar.gz | tar xfz - && \
./docker-utils-master/install.sh && \
rm -Rf ./docker-utils-master && \
# Install backup support
curl -Ls https://github.com/nimmis/backup/archive/master.tar.gz | tar xfz - && \
./backup-master/install.sh all && \
rm -Rf ./backup-master && \
# remove extra packages
apk del curl && \
# fix container bug for syslog
sed -i "s|\*.emerg|\#\*.emerg|" /etc/rsyslog.conf && \
sed -i 's/$ModLoad imklog/#$ModLoad imklog/' /etc/rsyslog.conf && \
sed -i 's/$KLogPermitNonKernelFacility on/#$KLogPermitNonKernelFacility on/' /etc/rsyslog.conf && \
# remove cached info
rm -rf /var/cache/apk/* /tmp /tmp*
COPY script_base/. /
VOLUME /backup
ENV HOME /root
WORKDIR /root
CMD ["/boot.sh"]
# ----------------------------------------------
# alpineglibc LAYER
# credits: https://github.com/nimmis/docker-alpine-glibc
# ----------------------------------------------
FROM alpinebase AS alpineglibc
ARG GLIBC_VERSION
RUN set -eux && apk --update --no-cache add \
ca-certificates wget && \
# install glibc
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget -q -O glibc-"${GLIBC_VERSION}".apk \
https://github.com/sgerrand/alpine-pkg-glibc/releases/download/"${GLIBC_VERSION}"/glibc-"${GLIBC_VERSION}".apk && \
apk add glibc-"${GLIBC_VERSION}".apk && \
rm glibc-"${GLIBC_VERSION}".apk && \
# remove un-needed stuff
apk del ca-certificates wget && \
rm -rf /var/cache/apk/*
# ----------------------------------------------
# BUILDER LAYER
# credits: https://github.com/nimmis/docker-resilio-sync
# ----------------------------------------------
FROM alpine:${ALPINE_VERSION} AS builder
ARG VERSION
ARG APP_NAME
ARG BINARY_NAME
RUN set -eux && apk --update --no-cache add \
ca-certificates curl upx
# Download app
# https://help.resilio.com/hc/en-us/articles/206178924-Installing-Sync-package-on-Linux
# https://download-cdn.resilio.com/2.7.2.1375/Debian/resilio-sync_2.7.2.1375-1_amd64.deb
WORKDIR /tmp
RUN set -eux && curl https://download-cdn.resilio.com/"${VERSION}"/linux-x64/resilio-sync_x64.tar.gz | tar xfz - && \
mv "${BINARY_NAME}" /usr/local/bin && \
apk del ca-certificates curl && \
rm -rf /var/cache/apk/* /tmp
# Compress binary
RUN set -eux && upx /usr/local/bin/"${BINARY_NAME}" && \
upx -t /usr/local/bin/"${BINARY_NAME}"
# ----------------------------------------------
# FINAL LAYER
# ----------------------------------------------
FROM alpineglibc AS final
ARG VERSION
ARG APP_NAME
ARG USER
ARG ALPINE_VERSION
ARG BINARY_NAME
ENV APP_NAME="${APP_NAME}"
ENV VERSION="${VERSION}"
ENV ALPINE_VERSION="${ALPINE_VERSION}"
ENV CREATED_DATE="$(date "+%Y-%m-%d_%HH%Ms%S")"
ENV SOURCE_COMMIT="$(git rev-parse --short HEAD)"
# resilio configurations
ENV RSLSYNC_SIZE="1024" \
RSLSYNC_TRASH="false" \
RSLSYNC_TRASH_TIME="0"
# credits: https://github.com/opencontainers/image-spec/blob/master/annotations.md
LABEL org.opencontainers.image.title="${APP_NAME}" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.description="See README.md" \
org.opencontainers.image.authors="Pascal Andy https://firepress.org/en/contact/" \
org.opencontainers.image.created="${CREATED_DATE}" \
org.opencontainers.image.revision="${SOURCE_COMMIT}" \
org.opencontainers.image.licenses="GNUv3. See README.md" \
org.firepress.image.user="${USER}" \
org.firepress.image.alpineversion="{ALPINE_VERSION}" \
org.firepress.image.field1="not_set" \
org.firepress.image.field2="not_set" \
org.firepress.image.schemaversion="1.0"
COPY script_glibc/. /
COPY --from=builder /usr/local/bin/"${BINARY_NAME}" /usr/local/bin/"${BINARY_NAME}"
VOLUME /data
EXPOSE 33333