Skip to content

Commit a30f769

Browse files
committed
chore(image): add git to container image
1 parent 9e19f35 commit a30f769

File tree

7 files changed

+35
-17
lines changed

7 files changed

+35
-17
lines changed

docker/Dockerfile

+7-15
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,18 @@ ENV DRYCC_UID=1001 \
1616

1717
COPY --from=build /usr/local/bin/drycc /usr/local/bin/drycc
1818

19-
ADD docker/entrypoint.sh /entrypoint.sh
19+
ADD docker/rootfs /
2020

21-
RUN install-packages bash-completion \
21+
RUN install-packages bash-completion git vim \
2222
&& groupadd drycc --gid ${DRYCC_GID} \
2323
&& useradd drycc -u ${DRYCC_UID} -g ${DRYCC_GID} -s /bin/bash -m -d ${DRYCC_HOME_DIR} \
24-
&& mkdir -p /etc/bash_completion.d \
25-
&& drycc completion bash > /etc/bash_completion.d/drycc \
26-
&& chown ${DRYCC_GID}:${DRYCC_UID} /usr/local/bin \
24+
&& mkdir -p /etc/wait \
25+
&& chown ${DRYCC_GID}:${DRYCC_UID} /etc/wait /usr/local/bin \
2726
&& echo 'alias cd="echo \"cd: restricted\"; false"' > ${DRYCC_HOME_DIR}/.bash_aliases \
2827
&& echo 'alias unalias="echo \"unalias: restricted\"; false"' >> ${DRYCC_HOME_DIR}/.bash_aliases \
29-
&& ln -s /usr/bin/ls /usr/local/bin/ls \
30-
&& ln -s /usr/bin/cat /usr/local/bin/cat \
31-
&& ln -s /usr/bin/sed /usr/local/bin/sed \
32-
&& ln -s /usr/bin/find /usr/local/bin/find \
33-
&& ln -s /usr/bin/bash /usr/local/bin/bash \
34-
&& ln -s /usr/bin/mkdir /usr/local/bin/mkdir \
35-
&& ln -s /usr/bin/sleep /usr/local/bin/sleep \
36-
&& ln -s /usr/bin/dircolors /usr/local/bin/dircolors \
37-
&& ln -s /usr/bin/tini /usr/local/bin/tini \
38-
&& ln -s /usr/bin/init-stack /usr/local/bin/init-stack
28+
&& ln /usr/bin/{ls,git,date,vim,cat,sed,clear,find,flock,bash,mkdir,sleep,dircolors} /usr/local/bin/ \
29+
&& apt autoremove python3 -yq \
30+
&& rm -rf /var/lib/apt/lists/* /sbin /usr/sbin /usr/bin
3931

4032
ENTRYPOINT [ "/entrypoint.sh" ]
4133

docker/entrypoint.sh renamed to docker/rootfs/entrypoint.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/local/bin/bash
22

33
if [ -n "$DRYCC_USER" ] && [ -n "$DRYCC_TOKEN" ] && [ -n "$DRYCC_ENDPOINT" ]; then
44
mkdir -p ~/.drycc
@@ -19,9 +19,15 @@ _main() {
1919
if [ "$1" == 'bash' ]; then
2020
shift
2121
exec bash "$@"
22+
elif [ "$1" == 'wait' ]; then
23+
shift
24+
/etc/bash_completion.d/timeout
25+
while [ "$(date +%s)" -le "$(flock -x -w 10 /tmp/timeout.lock cat /etc/wait/timeout)" ]; do
26+
sleep ${TIMEOUT:-30}
27+
done
2228
else
2329
exec drycc "$@"
2430
fi
2531
}
2632

27-
_main "$@"
33+
_main "$@"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/local/bin/bash
2+
3+
source <(drycc completion bash)
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/local/bin/bash
2+
3+
export PS1="\e[32m> \e[0m"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/local/bin/bash
2+
3+
flock -x -w 10 /tmp/timeout.lock cat << EOF > /etc/wait/timeout
4+
$(($(date +%s) + ${TIMEOUT:-30}))
5+
EOF

internal/utils/utils_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ func TestLoadProject(t *testing.T) {
3535

3636
assert.NoError(t, os.Chdir(name))
3737

38+
os.Setenv("DRYCC_APP", "testapp")
39+
appID, _, err = LoadAppSettings(filename, "")
40+
assert.NoError(t, err)
41+
assert.Equal(t, appID, "testapp", "app")
42+
os.Unsetenv("DRYCC_APP")
43+
3844
appID, _, err = LoadAppSettings(filename, "")
3945
assert.NoError(t, err)
4046
assert.Equal(t, appID, filepath.Base(name), "app")

pkg/git/git.go

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ func DetectAppName(cmd Cmd, host string) (string, error) {
108108

109109
// Don't return an error if remote can't be found, return directory name instead.
110110
if err != nil {
111+
if appName, ok := os.LookupEnv("DRYCC_APP"); ok {
112+
return appName, nil
113+
}
111114
dir, err := os.Getwd()
112115
return strings.ToLower(filepath.Base(dir)), err
113116
}

0 commit comments

Comments
 (0)