@@ -19,7 +19,6 @@ phases:
19
19
java : latest
20
20
21
21
commands :
22
- - bash buildspec/setup-github-token.sh
23
22
- ' >/dev/null add-apt-repository universe'
24
23
- ' >/dev/null apt-get -qq install -y apt-transport-https'
25
24
- ' >/dev/null apt-get -qq update'
@@ -33,22 +32,38 @@ phases:
33
32
- ' python3.8 --version'
34
33
# Dependencies for running vscode.
35
34
- ' >/dev/null apt-get -yqq install libatk1.0-0 libgtk-3-dev libxss1 xvfb libasound2 libasound2-plugins'
36
- - ' >/dev/null pip3 install --upgrade aws-sam-cli'
37
- # Print info about sam (version, location, …).
38
- - ' pip3 show aws-sam-cli'
39
- - ' >/dev/null pip3 install --upgrade awscli'
40
- - ' >/dev/null pip3 install pylint'
41
- # Install latest version of Go (known to 'goenv')
42
- - ' >/dev/null VERSION=$(goenv install --list | tail -n 1) && 2>/dev/null goenv install $VERSION'
43
- - ' >/dev/null goenv global $VERSION && go env -w GOPROXY=direct'
44
- - go version
45
35
# login to DockerHub so we don't get throttled
46
- - docker login --username $(echo $DOCKER_HUB_TOKEN | jq -r '.username') --password $(echo $DOCKER_HUB_TOKEN | jq -r '.password') || true
36
+ # - docker login --username $(echo $DOCKER_HUB_TOKEN | jq -r '.username') --password $(echo $DOCKER_HUB_TOKEN | jq -r '.password') || true
47
37
# increase file watcher count so CodeLens tests do not fail unexpectedly (ENOSPC error)
48
38
- sysctl fs.inotify.max_user_watches=524288
39
+ # start Docker
40
+ # - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay&
41
+ - timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
42
+ #
43
+ # Prepare env for unprivileged user.
44
+ #
45
+ - |
46
+ # - adduser --gecos GECOS --disabled-password codebuild-user
47
+ mkdir ~codebuild-user || true
48
+ chown -R codebuild-user:codebuild-user ~codebuild-user
49
+ chown -R codebuild-user:codebuild-user .
50
+ chmod +x ~codebuild-user
51
+ ls -ld ~codebuild-user
52
+ # Add user to "docker" group.
53
+ # - usermod -aG docker codebuild-user
54
+ # Ensure that "docker" group has permissions to the socket.
55
+ # - chown codebuild-user /var/run/docker.sock
56
+ - chmod 666 /var/run/docker.sock
49
57
50
58
pre_build :
59
+ run-as : codebuild-user
60
+ env :
61
+ variables :
62
+ HOME : /home/codebuild-user
51
63
commands :
64
+ # codebuild ignores the env.variables.HOME declaration above...?
65
+ - export HOME=/home/codebuild-user
66
+ - bash buildspec/setup-github-token.sh
52
67
# If present, log into CodeArtifact. Provides a nice safety net in case NPM is down.
53
68
# Should only affect tests run through IDEs team-hosted CodeBuild.
54
69
- |
@@ -59,15 +74,29 @@ phases:
59
74
echo "CodeArtifact connection failed. Falling back to npm"
60
75
fi
61
76
fi
62
- # make sure that SAM is in the path, is not automatically done on CodeBuild
63
- - USER_BASE_PATH=$(python -m site --user-base) && export PATH=$PATH:$USER_BASE_PATH/bin
64
- # start Docker
65
- - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay&
66
- - timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
77
+ # Where non-root "pip3 install" puts things:
78
+ - ' export PATH="$HOME/.local/bin:$PATH"'
79
+ - ' >/dev/null pip3 install --upgrade aws-sam-cli'
80
+ - ' >/dev/null pip3 install --upgrade awscli'
81
+ # Print info about sam (version, location, …).
82
+ - ' pip3 show aws-sam-cli'
83
+ - ' sam --version'
84
+ # Install latest version of Go (known to 'goenv')
85
+ # - eval "$(goenv init -)"
86
+ # - 'export PATH="$GOROOT/bin:$PATH:$GOPATH/bin"'
87
+ # - '>/dev/null VERSION=$(goenv install --list | tail -n 1) && 2>/dev/null goenv install $VERSION'
88
+ # - '>/dev/null goenv global $VERSION && go env -w GOPROXY=direct'
89
+ # - go version
67
90
68
91
build :
92
+ run-as : codebuild-user
93
+ env :
94
+ variables :
95
+ HOME : /home/codebuild-user
69
96
commands :
70
- - npm ci --unsafe-perm
97
+ # codebuild ignores the env.variables.HOME declaration above...?
98
+ - export HOME=/home/codebuild-user
99
+ - npm ci
71
100
- xvfb-run npm run testInteg
72
101
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
73
102
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g')
0 commit comments