Skip to content

Commit 8c46ad4

Browse files
committed
Merge branch 'publish'
2 parents 759e3b0 + f1f0b4f commit 8c46ad4

File tree

8 files changed

+76
-150
lines changed

8 files changed

+76
-150
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fi
1818

1919
# build sandbox
2020
if [[ ${TASK} == "shell" ]]; then
21-
docker-compose run sandbox bash
21+
docker-compose run sandbox
2222
fi
2323

2424
# build dependencies and extensions.

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ services:
1616
image: "codecasts/php-alpine:sandbox-v${ALPINE_VERSION}"
1717
# enable tty.
1818
tty: true
19+
tmpfs:
20+
'/tmp:exec,mode=1755'
1921
# build config.
2022
build:
2123
context: "sandbox"

repo/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
v*/php-*
1+
!.gitignore
2+
v*/*/*/*.apk
3+
v*/*/*/*.tar.gz

sandbox/Dockerfile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ ARG APK_PACKAGER
1515
ARG APK_MAINTAINER
1616

1717
# make args available as env vars.
18-
ENV ALPINE_VERSION=${ALPINE_VERSION} \
18+
ENV ENV="/etc/profile" \
19+
ALPINE_VERSION=${ALPINE_VERSION} \
1920
APK_PACKAGER=${APK_PACKAGER} \
2021
APK_MAINTAINER=${APK_MAINTAINER} \
2122
APORTS=/home/sandbox/scripts \
@@ -24,8 +25,7 @@ ENV ALPINE_VERSION=${ALPINE_VERSION} \
2425
EDITOR=nano
2526

2627
# install some required tools.
27-
RUN apk add \
28-
--update-cache \
28+
RUN apk add --update-cache \
2929
alpine-sdk \
3030
aports-build \
3131
ncurses \
@@ -34,13 +34,13 @@ RUN apk add \
3434
nano
3535

3636
# 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
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
4039

41-
# add entrypoint script and a cool bashrc.
42-
ADD entrypoint.sh /opt/php-alpine/entrypoint.sh
43-
ADD bashrc /home/sandbox/.bashrc
40+
# add opt scripts.
41+
ADD opt /opt
42+
# add etc configuration.
43+
ADD etc /etc
4444

4545
# ADD THE PUBLIC KEY FOR REPOS.
4646
# COPY ${APK_PUB_KEY} /etc/apk/keys/php-alpine.rsa.pub
@@ -54,11 +54,13 @@ RUN adduser -D -u 1000 sandbox && \
5454
mkdir -p /var/cache/apk && \
5555
ln -s /var/cache/apk /etc/apk/cache && \
5656
echo "sandbox ALL = ( ALL ) NOPASSWD: ALL" >> /etc/sudoers && \
57+
echo "Set disable_coredump false" >> /etc/sudo.conf && \
5758
sed -i "/export JOBS=.*/c\export JOBS=$(cat /proc/cpuinfo | grep '^processor\s*:\s[0-9]*$' | wc -l)" /etc/abuild.conf && \
5859
sed -i "/#USE_CCACHE=.*/c\USE_CCACHE=1" /etc/abuild.conf && \
5960
sed -i "/#PACKAGER=.*/c\PACKAGER=\"${APK_PACKAGER}\"" /etc/abuild.conf && \
6061
sed -i "/#MAINTAINER=.*/c\MAINTAINER=\"${APK_MAINTAINER}\"" /etc/abuild.conf && \
61-
chown -R sandbox:sandbox /home/sandbox
62+
chown -R sandbox:sandbox /home/sandbox && \
63+
chown -R sandbox:sandbox /opt/php-alpine
6264

6365
# required for running "aports-build" tool.
6466
RUN mkdir -p /var/run/mqtt-exec.aports-build && \
@@ -79,4 +81,4 @@ ENTRYPOINT ["/opt/php-alpine/entrypoint.sh"]
7981
WORKDIR "/home/sandbox/scripts"
8082

8183
# use bash as default command.
82-
CMD ["/bin/bash"]
84+
CMD ["/usr/bin/env", "ash"]

sandbox/bashrc

Lines changed: 0 additions & 117 deletions
This file was deleted.

sandbox/entrypoint.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

sandbox/etc/profile.d/color_prompt.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# enable prompt colors: red prompt for root and green for users.
2+
function ambientum_color_prompt()
3+
{
4+
# B=bold
5+
local BOLD="\[\e[1m\]"
6+
# W=white
7+
local WHITE="\[\e[37m\]"
8+
# D=dim
9+
local DIM="\[\e[2m\]"
10+
# R=reset
11+
local RESET="\[\e[0;0;0m\]"
12+
13+
# T=theme (default green)
14+
local THEME="\[\e[32m\]"
15+
# set T as red when root.
16+
if [ "$1" = root ]; then THEME="\[\e[31m\]"; fi
17+
18+
# build PS1 variable parts.
19+
local PS1_USER="${BOLD}${DIM}${WHITE}u:${RESET}${BOLD}${WHITE}\u"
20+
local PS1_HOST="${BOLD}${DIM}${WHITE}h:${RESET}${BOLD}${THEME}\h"
21+
local PS1_CURD="${BOLD}${DIM}${WHITE}w:${RESET}${BOLD}${WHITE}\w"
22+
local PS1_SIGN="${BOLD}${THEME}\$"
23+
24+
# set PS1
25+
export PS1="${RESET}${PS1_USER} ${PS1_HOST} ${PS1_CURD} ${PS1_SIGN} ${RESET}"
26+
}
27+
28+
# call color prompt helper.
29+
ambientum_color_prompt "$USER"
30+
31+
# unset previous function.
32+
unset -f ambientum_color_prompt

sandbox/opt/php-alpine/entrypoint.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env ash
2+
3+
# set php-alpine bin directory on path.
4+
export PATH=/opt/php-alpine/bin:$PATH
5+
6+
# trust the locally mounted public key and fix permissions.
7+
sudo cp /home/sandbox/.abuild/php-alpine.rsa.pub /etc/apk/keys/php-alpine.rsa.pub
8+
sudo chmod u=rw,go=r /etc/apk/keys/php-alpine.rsa.pub
9+
10+
# fix home dir owner permissions.
11+
sudo chown -R sandbox:sandbox /home/sandbox
12+
13+
# determine cpu count.
14+
ABUILD_JOBS=$(grep -c '^processor\s*:\s[0-9]*$' < /proc/cpuinfo)
15+
# configure JOBS variable as cpu count on abuild.conf file.
16+
sudo sed -i "/export JOBS=.*/c\export JOBS=$ABUILD_JOBS" /etc/abuild.conf
17+
18+
# source env files generated during docker build.
19+
if [ -f ~/.build_env ]; then
20+
# shellcheck disable=SC1090
21+
. ~/.build_env
22+
fi
23+
24+
# run the original command
25+
exec "$@"

0 commit comments

Comments
 (0)