1- # Alpine 3.x Sandbox Dockerfile
2- # This image is used to build PHP packages.
1+ # Alpicetera - Building sandbox image.
32
4- # IMAGE ARGUMENT
3+ # arg for using a specific Alpine version (before FROM)
54ARG ALPINE_VERSION
65
7- # ALPINE 3.x .
6+ # use alpine version from argument as base/from image .
87FROM alpine:$ALPINE_VERSION
98
10- # MAINTAINER .
9+ # maintainer label .
1110MAINTAINER Diego Hernandes <iamhernandev@gmail.com>
1211
13- # AFTER IMAGE DEFINITION ARGUMENTS
12+ # declare required build arguments.
1413ARG ALPINE_VERSION
15- ARG PHP_VERSION
1614ARG APK_PACKAGER
1715ARG APK_MAINTAINER
1816
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.
3242ADD entrypoint.sh /opt/php-alpine/entrypoint.sh
3343ADD bashrc /home/sandbox/.bashrc
3444
@@ -41,32 +51,32 @@ RUN adduser -D -u 1000 sandbox && \
4151 mkdir -p /var/cache/distfiles && \
4252 chmod a+w /var/cache/distfiles && \
4353 chmod +x /opt/php-alpine/entrypoint.sh && \
54+ mkdir -p /var/cache/apk && \
55+ ln -s /var/cache/apk /etc/apk/cache && \
4456 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 && \
4559 sed -i "/#PACKAGER=.*/c\P ACKAGER=\" ${APK_PACKAGER}\" " /etc/abuild.conf && \
4660 sed -i "/#MAINTAINER=.*/c\M AINTAINER=\" ${APK_MAINTAINER}\" " /etc/abuild.conf && \
4761 chown -R sandbox:sandbox /home/sandbox
4862
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
5467
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.
6369USER sandbox
6470
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.
6676ENTRYPOINT ["/opt/php-alpine/entrypoint.sh" ]
6777
68- # START ON SANDBOX USER HOME .
69- WORKDIR "/home/sandbox/php-${PHP_VERSION} "
78+ # set container workdir .
79+ WORKDIR "/home/sandbox/scripts "
7080
71- # START WITH BASH .
81+ # use bash as default command .
7282CMD ["/bin/bash" ]
0 commit comments