-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (61 loc) · 2.57 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (61 loc) · 2.57 KB
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
FROM python:3.13-slim-bookworm as sphinxsearch_base
RUN apt-get update && \
apt-get install -y \
cron \
default-mysql-client \
gettext-base \
gosu \
jq \
procps \
rsync \
sphinxsearch \
vim && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
gosu nobody true && \
# set up cron for non root user
chmod gu+rw /var/run && \
chmod gu+s /usr/sbin/cron &&\
mkfifo /tmp/stdout /tmp/stderr && \
chmod 0666 /tmp/stdout /tmp/stderr
# set up geodata, file permissions, copy files and run container as geodata
FROM sphinxsearch_base as sphinxsearch_geodata
# add geodata user, same uid/gid as the EFS owner is needed here
RUN groupadd -r geodata -g 2500 && \
useradd -u 2500 -r -g geodata -s /sbin/nologin --create-home geodata && \
# create mountpoint for Amazon EFS CSI driver
install -o geodata -g geodata -d /var/local/ && \
# create mountpoint folder for infra-vhost/k8s ebs/ssd volume
install -o geodata -g geodata -d /var/lib/sphinxsearch/data/index/ && \
# change ownerships to geodata which will run the service or the maintenance scripts
# and mount the efs folder
chown -R geodata:geodata /var/run/sphinxsearch/ && \
chown -R geodata:geodata /var/log/sphinxsearch/ && \
chown -R geodata:geodata /etc/sphinxsearch && \
# install psycopg2 via pip, because the apt package (python3-psycopg2) is built for Debian's
# default python3.11, not the python version used in this image (3.13).
gosu geodata pip3 install psycopg2-binary==2.9.10
FROM sphinxsearch_geodata
# Define the build argument with a default value
ARG VERSION="unknown"
# Make the argument available for use in the Dockerfile
ENV VERSION=${VERSION}
# Create the directory if it doesn't exist and save the value of the VERSION argument to /usr/local/share/app/version.txt
RUN mkdir -p /usr/local/share/app && echo "${VERSION}" > /usr/local/share/app/version.txt && chown -R geodata:geodata /usr/local/share/app
ARG GIT_HASH=unknown
ARG GIT_BRANCH=unknown
ARG GIT_DIRTY=""
ARG AUTHOR=unknown
LABEL git.hash=$GIT_HASH
LABEL git.branch=$GIT_BRANCH
LABEL git.dirty="$GIT_DIRTY"
LABEL author=$AUTHOR
LABEL version=$VERSION
# copy sphinxsearch config and maintenance code
COPY --chown=geodata:geodata scripts/docker-* scripts/index-sync-rotate.sh scripts/pg2sphinx_trigger.py scripts/checker.sh scripts/sphinx_log_to_json.py /
COPY --chown=geodata:geodata conf /conf/
USER geodata
# default CMD
ENTRYPOINT [ "/docker-entry.sh" ]
# run service with the following script if no CMDs are sent to docker run / default
CMD ["/docker-cmd.sh"]