forked from sopel-irc/docker-sopel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
107 lines (92 loc) · 2.95 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
## Build Arguments ##
#####################
## Set the python image tag to use as the base image.
# See https://hub.docker.com/_/python?tab=tags for a list of valid tags.
# Set default below to desired Python version.
ARG PYTHON_TAG=3.12-alpine
##
## Set the UID/GID that sopel will run and make files/folders as.
# For security, these values are set past the upper limit of named users in most
# linux environments. `chown` any volume mounts to the IDs specified here, or
# change to match your GID (and UID if desired) if you think its okay ¯\_(ツ)_/¯
ARG SOPEL_GID=100000
ARG SOPEL_UID=100000
##
## Set the repository used to pull the sopel source
# Set Docker build-arg SOPEL_REPO with private fork, or change default below
# as desired. Any valid Git URL is acceptable.
ARG SOPEL_REPO=https://github.com/sopel-irc/sopel.git
##
## Set the specific branch/commit for the source
# This can be a branch name, release/tag, or even specific commit hash.
# Set Docker build-arg SOPEL_BRANCH, or replace the default value below.
ARG SOPEL_BRANCH=v8.0.1
##
## Do not modify below this !! ##
#################################
#####
### STAGE 1: Pull latest source
#####
FROM alpine:latest AS git-fetch
ARG SOPEL_REPO
ARG SOPEL_BRANCH
RUN set -ex \
&& apk add --no-cache --virtual .git \
git \
&& git clone \
--depth 1 --branch ${SOPEL_BRANCH} \
${SOPEL_REPO} /sopel-src \
&& apk del \
.git
#####
#####
#####
### STAGE 2: Install Sopel
#####
FROM python:${PYTHON_TAG}
# Pre-set ARGs
ARG SOPEL_BRANCH
# Injected ARGs
ARG BUILD_DATE
ARG VCS_REF
ARG DOCKERFILE_VCS_REF
LABEL maintainer="Humorous Baby <[email protected]>" \
org.label-schema.build-date="${BUILD_DATE}" \
org.label-schema.name="sopel" \
org.label-schema.description=" \
Sopel, the Python IRC bot. \
For stand-alone or compose/stack service use." \
org.label-schema.url="https://sopel.chat" \
org.label-schema.vcs-url="https://github.com/sopel-irc/sopel" \
org.label-schema.vcs-ref="${VCS_REF}" \
org.label-schema.version="Python ${PYTHON_VERSION}/Sopel ${SOPEL_BRANCH}" \
org.label-schema.schema-version="1.0" \
dockerfile.vcs-url="https://github.com/sopel-irc/docker-sopel" \
dockerfile.vcf-ref="${DOCKERFILE_VCS_REF}"
ARG SOPEL_GID
ARG SOPEL_UID
RUN set -ex \
&& apk add --no-cache \
shadow \
su-exec \
&& apk add --no-cache --virtual .build-deps \
gcc \
build-base \
\
&& addgroup -g ${SOPEL_GID} sopel \
&& adduser -u ${SOPEL_UID} -G sopel -h /home/sopel -s /bin/ash sopel -D \
\
&& mkdir /home/sopel/.sopel \
&& chown sopel:sopel /home/sopel/.sopel
WORKDIR /home/sopel
COPY --from=git-fetch --chown=sopel:sopel /sopel-src /home/sopel/sopel-src
RUN set -ex \
&& cd ./sopel-src \
&& su-exec sopel python -m pip install . \
&& cd .. \
&& rm -rf ./sopel-src \
&& apk del .build-deps
VOLUME [ "/home/sopel/.sopel" ]
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "sopel" ]