Skip to content

Commit 4f51727

Browse files
committed
Run docker as a non root user to work around permissions issue caused by upgrading to alpine 3.14
1 parent 0d19eea commit 4f51727

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
FROM alpine:3.13
1+
FROM node:16-alpine3.14
22

3-
RUN apk --update --no-cache add nodejs npm python3 py3-pip jq curl bash git docker && \
4-
ln -sf /usr/bin/python3 /usr/bin/python
3+
RUN apk --update --no-cache add python3 py3-pip jq curl bash git docker sudo && \
4+
ln -sf /usr/bin/python3 /usr/bin/python && \
5+
addgroup github && adduser -G github -D github && \
6+
echo '%github ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/github
57

68
COPY --from=golang:alpine /usr/local/go/ /usr/local/go/
79
ENV PATH="/usr/local/go/bin:${PATH}"
810

911
COPY entrypoint.sh /entrypoint.sh
1012

13+
USER github:github
14+
1115
ENTRYPOINT ["/entrypoint.sh"]

entrypoint.sh

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,34 @@ function parseInputs(){
1010
fi
1111
}
1212

13-
function installTypescript(){
14-
npm install typescript
13+
function installNpmPackage(){
14+
package=$1
15+
scope=$2
16+
echo "Install $package with scope $scope"
17+
18+
if [ "${INPUT_DEBUG_LOG}" == "true" ] && [ "$scope" == "local" ]; then
19+
npm install $package
20+
elif [ "${INPUT_DEBUG_LOG}" == "true" ] && [ "$scope" == "global" ]; then
21+
sudo npm install -g $package
22+
elif [ "$scope" == "local" ]; then
23+
npm install $package --log-level=error --no-fund --no-audit $package >/dev/null 2>&1
24+
else
25+
sudo npm install -g --log-level=error --no-fund --no-audit $package >/dev/null 2>&1
26+
fi
27+
28+
if [ "${?}" -ne 0 ]; then
29+
echo "Failed to install $package"
30+
else
31+
echo "Successful install $package"
32+
fi
1533
}
1634

1735
function installAwsCdk(){
1836
echo "Install aws-cdk ${INPUT_CDK_VERSION}"
1937
if [ "${INPUT_CDK_VERSION}" == "latest" ]; then
20-
if [ "${INPUT_DEBUG_LOG}" == "true" ]; then
21-
npm install -g aws-cdk
22-
else
23-
npm install -g aws-cdk >/dev/null 2>&1
24-
fi
25-
26-
if [ "${?}" -ne 0 ]; then
27-
echo "Failed to install aws-cdk ${INPUT_CDK_VERSION}"
28-
else
29-
echo "Successful install aws-cdk ${INPUT_CDK_VERSION}"
30-
fi
38+
installNpmPackage aws-cdk global
3139
else
32-
if [ "${INPUT_DEBUG_LOG}" == "true" ]; then
33-
npm install -g aws-cdk@${INPUT_CDK_VERSION}
34-
else
35-
npm install -g aws-cdk@${INPUT_CDK_VERSION} >/dev/null 2>&1
36-
fi
37-
38-
if [ "${?}" -ne 0 ]; then
39-
echo "Failed to install aws-cdk ${INPUT_CDK_VERSION}"
40-
else
41-
echo "Successful install aws-cdk ${INPUT_CDK_VERSION}"
42-
fi
40+
installNpmPackage aws-cdk@${INPUT_CDK_VERSION} global
4341
fi
4442
}
4543

@@ -99,7 +97,7 @@ ${output}
9997
function main(){
10098
parseInputs
10199
cd ${GITHUB_WORKSPACE}/${INPUT_WORKING_DIR}
102-
installTypescript
100+
installNpmPackage typescript local
103101
installAwsCdk
104102
installPipRequirements
105103
runCdk ${INPUT_CDK_ARGS}

0 commit comments

Comments
 (0)