1
- # Alpine 3.x Sandbox Dockerfile
2
- # This image is used to build PHP packages.
1
+ # Alpicetera - Building sandbox image.
3
2
4
- # IMAGE ARGUMENT
3
+ # arg for using a specific Alpine version (before FROM)
5
4
ARG ALPINE_VERSION
6
5
7
- # ALPINE 3.x .
6
+ # use alpine version from argument as base/from image .
8
7
FROM alpine:$ALPINE_VERSION
9
8
10
- # MAINTAINER .
9
+ # maintainer label .
11
10
MAINTAINER Diego Hernandes <
[email protected] >
12
11
13
- # AFTER IMAGE DEFINITION ARGUMENTS
12
+ # declare required build arguments.
14
13
ARG ALPINE_VERSION
15
- ARG PHP_VERSION
16
14
ARG APK_PACKAGER
17
15
ARG APK_MAINTAINER
18
16
19
- # TERM CONFIG.
20
- ENV TERM=xterm-256color \
21
- COLORTERM=truecolor
22
-
23
- # ADD SDK AND BASIC TOOLS.
24
- RUN apk add --update-cache alpine-sdk ncurses sudo git bash nano
25
-
26
- # CONFIGURE ALPINE REPOSITORIES AND PHP BUILD DIR.
27
- RUN echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/main" > /etc/apk/repositories && \
28
- echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community" >> /etc/apk/repositories && \
29
- echo "/home/sandbox/packages/php-${PHP_VERSION}" >> /etc/apk/repositories
30
-
31
- # ADD THE START SCRIPT.
17
+ # make args available as env vars.
18
+ ENV ALPINE_VERSION=${ALPINE_VERSION} \
19
+ APK_PACKAGER=${APK_PACKAGER} \
20
+ APK_MAINTAINER=${APK_MAINTAINER} \
21
+ APORTS=/home/sandbox/scripts \
22
+ TERM=xterm-256color \
23
+ COLORTERM=truecolor \
24
+ EDITOR=nano
25
+
26
+ # install some required tools.
27
+ RUN apk add \
28
+ --update-cache \
29
+ alpine-sdk \
30
+ aports-build \
31
+ ncurses \
32
+ sudo \
33
+ bash \
34
+ nano
35
+
36
+ # configure APK repositories.
37
+ # RUN echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/main" > /etc/apk/repositories && \
38
+ # echo "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community" >> /etc/apk/repositories
39
+ # echo "/home/sandbox/packages/php-${PHP_VERSION}" >> /etc/apk/repositories
40
+
41
+ # add entrypoint script and a cool bashrc.
32
42
ADD entrypoint.sh /opt/php-alpine/entrypoint.sh
33
43
ADD bashrc /home/sandbox/.bashrc
34
44
@@ -41,32 +51,32 @@ RUN adduser -D -u 1000 sandbox && \
41
51
mkdir -p /var/cache/distfiles && \
42
52
chmod a+w /var/cache/distfiles && \
43
53
chmod +x /opt/php-alpine/entrypoint.sh && \
54
+ mkdir -p /var/cache/apk && \
55
+ ln -s /var/cache/apk /etc/apk/cache && \
44
56
echo "sandbox ALL = ( ALL ) NOPASSWD: ALL" >> /etc/sudoers && \
57
+ sed -i "/export JOBS=.*/c\e xport JOBS=$(cat /proc/cpuinfo | grep '^processor\s *:\s [0-9]*$' | wc -l)" /etc/abuild.conf && \
58
+ sed -i "/#USE_CCACHE=.*/c\U SE_CCACHE=1" /etc/abuild.conf && \
45
59
sed -i "/#PACKAGER=.*/c\P ACKAGER=\" ${APK_PACKAGER}\" " /etc/abuild.conf && \
46
60
sed -i "/#MAINTAINER=.*/c\M AINTAINER=\" ${APK_MAINTAINER}\" " /etc/abuild.conf && \
47
61
chown -R sandbox:sandbox /home/sandbox
48
62
49
- # generate build env vars.
50
- RUN echo "ALPINE_VERSION=${ALPINE_VERSION}" >> /home/sandbox/.build_env && \
51
- echo "PHP_VERSION=${PHP_VERSION}" >> /home/sandbox/.build_env && \
52
- echo "APK_PACKAGER=${APK_PACKAGER}" >> /home/sandbox/.build_env && \
53
- echo "APK_MAINTAINER=${APK_MAINTAINER}" >> /home/sandbox/.build_env
63
+ # required for running "aports-build" tool.
64
+ RUN mkdir -p /var/run/mqtt-exec.aports-build && \
65
+ chown -R sandbox:abuild /var/run/mqtt-exec.aports-build && \
66
+ chmod 755 /var/run/mqtt-exec.aports-build
54
67
55
- # REMOVE TEMP FILES.
56
- RUN mkdir -p /var/cache/apk && \
57
- ln -s /var/cache/apk /etc/apk/cache
58
-
59
- # FIX KEY PERMISSION.
60
- # RUN chmod u=rw,go=r /etc/apk/keys/php-alpine.rsa.pub
61
-
62
- # START ON SANDBOX USER.
68
+ # switch to sandbox user.
63
69
USER sandbox
64
70
65
- # CONFIGURE ENTRYPOINT.
71
+ # create some required directories.
72
+ RUN mkdir -p /home/sandbox/scripts && \
73
+ mkdir -p /home/sandbox/packages
74
+
75
+ # set entrypoint.
66
76
ENTRYPOINT ["/opt/php-alpine/entrypoint.sh" ]
67
77
68
- # START ON SANDBOX USER HOME .
69
- WORKDIR "/home/sandbox/php-${PHP_VERSION} "
78
+ # set container workdir .
79
+ WORKDIR "/home/sandbox/scripts "
70
80
71
- # START WITH BASH .
81
+ # use bash as default command .
72
82
CMD ["/bin/bash" ]
0 commit comments