Skip to content

Commit 0109227

Browse files
committed
preparation new sandbox
1 parent fd18b55 commit 0109227

File tree

3 files changed

+54
-42
lines changed

3 files changed

+54
-42
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ jobs:
103103
echo "" > .env
104104
echo -e "${{ secrets.PHP_ALPINE_RSA }}" > .abuild/php-alpine.rsa
105105
echo -e "${{ secrets.PHP_ALPINE_RSA_PUB }}" > .abuild/php-alpine.rsa.pub
106-
docker-compose run sandbox builder.sh --build --extra --main --extensions
106+
chmod -R 644 ${{ env.PA_BUILD_PATH }}/* || echo -e "error setting permissions"
107+
docker-compose run -w /home/sandbox/scripts/${{ env.PHP_VERSION_SLUG }} sandbox builder.sh --build --extra --main --extensions
107108
108109
# upload artifacts.
109110
- name: upload

docker-compose.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ services:
1313
# sandbox base image
1414
sandbox:
1515
# target image.
16-
image: "codecasts/php-alpine:sandbox-v${ALPINE_VERSION}-php-${PHP_VERSION}"
16+
image: "codecasts/php-alpine:sandbox-v${ALPINE_VERSION}"
1717
# enable tty.
1818
tty: true
1919
# build config.
2020
build:
2121
context: "sandbox"
2222
args:
2323
ALPINE_VERSION: ${ALPINE_VERSION}
24-
PHP_VERSION: ${PHP_VERSION}
24+
APK_MAINTAINER: ${APK_MAINTAINER}
25+
APK_PACKAGER: ${APK_PACKAGER}
2526
# declare volumes and mounting.
2627
volumes:
2728
- "./bin:/opt/php-alpine/bin"
28-
- "./scripts/v${ALPINE_VERSION}/php-${PHP_VERSION}:/home/sandbox/php-${PHP_VERSION}"
29+
- "./scripts/v${ALPINE_VERSION}:/home/sandbox/scripts"
2930
- "./.abuild:/home/sandbox/.abuild"
30-
- "./repo/v${ALPINE_VERSION}/php-${PHP_VERSION}:/home/sandbox/packages/php-${PHP_VERSION}"
31+
- "./repo/v${ALPINE_VERSION}:/home/sandbox/packages"
3132
- "php-alpine-cache-v${ALPINE_VERSION}:/var/cache/apk"
3233

3334
# sandbox for building on alpine edge.

sandbox/Dockerfile

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,44 @@
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)
54
ARG ALPINE_VERSION
65

7-
# ALPINE 3.x.
6+
# use alpine version from argument as base/from image.
87
FROM alpine:$ALPINE_VERSION
98

10-
# MAINTAINER.
9+
# maintainer label.
1110
MAINTAINER Diego Hernandes <[email protected]>
1211

13-
# AFTER IMAGE DEFINITION ARGUMENTS
12+
# declare required build arguments.
1413
ARG ALPINE_VERSION
15-
ARG PHP_VERSION
1614
ARG APK_PACKAGER
1715
ARG 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.
3242
ADD entrypoint.sh /opt/php-alpine/entrypoint.sh
3343
ADD 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\export JOBS=$(cat /proc/cpuinfo | grep '^processor\s*:\s[0-9]*$' | wc -l)" /etc/abuild.conf && \
58+
sed -i "/#USE_CCACHE=.*/c\USE_CCACHE=1" /etc/abuild.conf && \
4559
sed -i "/#PACKAGER=.*/c\PACKAGER=\"${APK_PACKAGER}\"" /etc/abuild.conf && \
4660
sed -i "/#MAINTAINER=.*/c\MAINTAINER=\"${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.
6369
USER 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.
6676
ENTRYPOINT ["/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.
7282
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)