-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
160 lines (144 loc) · 5.85 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
# Alpine Image
FROM alpine:3.21.2
# Build Arguments
ARG ALPINE_VERSION="3.21.2" \
IMAGE_VERSION="2.5.6" \
PIP_VERSION="24.3.1" \
PIPX_VERSION="1.7.1" \
PYTHON_VERSION="3.12.8" \
PYTHON_VERSION_SHORT="3.12" \
VDIRSYNCER_VERSION="0.19.3"
# Set up Environment
# Set Vdirsyncer config location
ENV VDIRSYNCER_CONFIG=/vdirsyncer/config \
# Set log file
LOG=/vdirsyncer/vdirsyncer.log \
# Set Autodiscover
AUTODISCOVER=false \
# Set Autosync
AUTOSYNC=false \
# Set Autoupdate
AUTOUPDATE=false \
# Set Cron Time
CRON_TIME='*/15 * * * *' \
# Set Timezone
TZ=Europe/Vienna \
# Set UID
UID="1000" \
# Set GID
GID="1000" \
# Set Vdirsyncer user
VDIRSYNCER_USER="vdirsyncer" \
# Set cron file
CRON_FILE="/etc/crontabs/vdirsyncer" \
# Set script path to run after sync complete
POST_SYNC_SCRIPT_FILE= \
# Set Pipx home
PIPX_HOME="/opt/pipx" \
# Set Pipx bin dir
PIPX_BIN_DIR="/usr/local/bin" \
# Supercronic log level
LOG_LEVEL=
# Update and install packages
RUN apk update \
&& apk add --no-cache --upgrade apk-tools \
&& apk upgrade --no-cache --available \
# Install Pip
&& apk add --no-cache py3-pip \
# Update Pip
&& pip install --upgrade --break-system-packages pip \
# Install Pipx
&& pip install --upgrade --break-system-packages pipx \
# For Curl Commands
&& apk add --no-cache curl \
# For TS
&& apk add --no-cache moreutils \
# For Timezone
&& apk add --no-cache tzdata \
# For Sudo Commands
#&& apk add --no-cache sudo \
# For Usermod
#&& apk add --no-cache shadow \
# For Scripts and Shell
&& apk add --no-cache bash \
# Nano Editor
&& apk add --no-cache nano \
# Cron Update
#&& apk add --update busybox-suid \
# Supercronic instead of Cron (for cronjobs)
&& apk add --no-cache supercronic \
# Clear cache
&& rm -rf /var/cache/apk/*
# Set up User
# Set up Group
RUN addgroup -g "${GID}" "${VDIRSYNCER_USER}" \
# Set up User
&& adduser \
-D \
# Add to Group
-G "${VDIRSYNCER_USER}" \
# Don't create home directory
#-H \
# Home directory
-h "/home/${VDIRSYNCER_USER}" \
# Set UID
-u "${UID}" \
# Set Username
"${VDIRSYNCER_USER}" \
# Remove root password
#&& passwd -d root \
# Set up Crontab file
&& touch "${CRON_FILE}"
# Full sudo access for vdirsyncer user
# RUN echo "vdirsyncer ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vdirsyncer
# Set up Workdir
WORKDIR /vdirsyncer
# Add Files
ADD files /files/
# Set up Timezone
RUN cp "/usr/share/zoneinfo/${TZ}" /etc/localtime \
&& echo "${TZ}" > /etc/timezone
# Healthcheck
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=1 \
CMD ps -ef | grep -e "supercronic" | grep -v -e "grep" || exit 1
# Labeling
LABEL maintainer="Bleala" \
version="${IMAGE_VERSION}" \
description="Vdirsyncer ${VDIRSYNCER_VERSION} on Alpine ${ALPINE_VERSION}, Pip ${PIP_VERSION}, Pipx ${PIPX_VERSION}, Python ${PYTHON_VERSION}" \
org.opencontainers.image.source="https://github.com/Bleala/Vdirsyncer-DOCKERIZED" \
org.opencontainers.image.url="https://github.com/Bleala/Vdirsyncer-DOCKERIZED"
# Vdirsyncer installation
RUN PIPX_HOME="${PIPX_HOME}" PIPX_BIN_DIR="${PIPX_BIN_DIR}" pipx install "vdirsyncer==${VDIRSYNCER_VERSION}" \
# For Vdirsyncer 0.18.0
#&& pip install requests-oauthlib
# For Vdirsyncer 0.19.x (Pip install)
#&& pip install aiohttp-oauthlib \
#&& pip install vdirsyncer[google] \
# For Vdirsyncer 0.19.x (Pipx install)
&& PIPX_HOME="${PIPX_HOME}" PIPX_BIN_DIR="${PIPX_BIN_DIR}" pipx inject vdirsyncer aiohttp-oauthlib \
&& PIPX_HOME="${PIPX_HOME}" PIPX_BIN_DIR="${PIPX_BIN_DIR}" pipx inject vdirsyncer vdirsyncer[google] \
# Update Path for Pipx
&& PIPX_HOME="${PIPX_HOME}" PIPX_BIN_DIR="${PIPX_BIN_DIR}" pipx ensurepath
# Fix Google redirect uri
# For Vdirsyncer 0.19.1 (Pip Install)
#RUN sed -i 's~f"http://{host}:{local_server.server_port}"~"http://127.0.0.1:8088"~g' /home/vdirsyncer/.local/lib/python3.10/site-packages/vdirsyncer/storage/google.py
# For Vdirsyncer 0.19.1 (Pipx Install)
#RUN sed -i 's~f"http://{host}:{local_server.server_port}"~"http://127.0.0.1:8088"~g' "/home/${VDIRSYNCER_USER}/.local/pipx/venvs/vdirsyncer/lib/python3.11/site-packages/vdirsyncer/storage/google.py"
# For Vdirsyncer 0.19.1 (Pipx, Global Install)
#RUN sed -i 's~f"http://{host}:{local_server.server_port}"~"http://127.0.0.1:8088"~g' "${PIPX_HOME}/venvs/vdirsyncer/lib/python${PYTHON_VERSION_SHORT}/site-packages/vdirsyncer/storage/google.py"
#For Vdirsyncer 0.18.0 - User install
#RUN sed -i 's~urn:ietf:wg:oauth:2.0:oob~http://127.0.0.1:8088~g' /home/vdirsyncer/.local/lib/python3.10/site-packages/vdirsyncer/storage/google.py
#For Vdirsyncer 0.18.0 - Root install
#RUN sed -i 's~urn:ietf:wg:oauth:2.0:oob~http://127.0.0.1:8088~g' /usr/lib/python3.10/site-packages/vdirsyncer/storage/google.py
# Change Permissions
RUN chmod -R +x /files/scripts \
&& chown -R "${UID}":"${GID}" /files \
&& chown -R "${UID}":"${GID}" /vdirsyncer \
&& chmod -R 755 /vdirsyncer \
&& chown "${UID}":"${GID}" "${CRON_FILE}" \
&& chmod 644 "${CRON_FILE}" \
&& chown -R "${VDIRSYNCER_USER}":"${VDIRSYNCER_USER}" "${PIPX_HOME}"
# Switch User
USER "${VDIRSYNCER_USER}"
# Entrypoint
ENTRYPOINT ["bash","/files/scripts/start.sh"]