@@ -3,57 +3,3 @@ FROM gitpod/workspace-full
33USER root
44
55RUN brew update && brew install awscli docker-credential-helper-ecr
6-
7- USER gitpod
8-
9- # below is an inline bash script to populate this container with a helper script to run at login
10- # this is really a terrible idea and why aws_init.sh is used instead
11- RUN <<'EOF' bash
12- set -e
13-
14-
15- mkdir -p /home/gitpod/.aws/
16-
17- cat <<'AWSINIT' > /home/gitpod/.aws/init.sh
18- # !/bin/bash
19- set -e
20-
21- # create the config for SSO login
22- # This assumes the below variables have been configured for this repo in gitpod
23- # https://www.gitpod.io/docs/environment-variables#using-the-account-settings
24- cat <<- AWSFILE > /home/gitpod/.aws/config
25- [default]
26- sso_start_url = ${AWS_SSO_URL}
27- sso_region = ${AWS_SSO_REGION}
28- sso_account_id = ${AWS_ACCOUNT_ID}
29- sso_role_name = ${AWS_ROLE_NAME}
30- region = ${AWS_REGION}
31- AWSFILE
32-
33- # update docker config to use ecr-login
34-
35- # make sure we have ecr-login
36- if [ ! -f /usr/local/bin/docker-credential-ecr-login ]; then
37- ECR_LATEST=$(curl -s https://api.github.com/repos/awslabs/amazon-ecr-credential-helper/releases/latest | jq -r ".tag_name" )
38- curl -o docker-credential-ecr-login -fSsL "https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/${ECR_LATEST##*v}/linux-arm64/docker-credential-ecr-login"
39- sudo mv docker-credential-ecr-login /usr/local/bin/docker-credential-ecr-login
40- sudo chmod +x /usr/local/bin/docker-credential-ecr-login
41- fi
42-
43- # if we don't have a .docker/config.json, create:
44-
45- if [ ! -d /home/gitpod/.docker ]; then
46- mkdir -p /home/gitpod/.docker && echo '{}' > /home/gitpod/.docker/config.json
47- elif [ ! -f /home/gitpod/.docker/config.json ]; then
48- echo '{}' > /home/gitpod/.docker/config.json
49- fi
50-
51- jq '.credHelpers["public.ecr.aws"]="ecr-login"' /home/gitpod/.docker/config.json > /home/gitpod/.docker/config_tmp.json
52- jq ".credHelpers[\" ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com\" ]=\" ecr-login\" " /home/gitpod/.docker/config_tmp.json > /home/gitpod/.docker/config.json
53-
54- AWSINIT
55-
56- chmod +x /home/gitpod/.aws/init.sh
57-
58- EOF
59-
0 commit comments