Skip to content

Commit

Permalink
devcontainer finished
Browse files Browse the repository at this point in the history
  • Loading branch information
aristosMiliaressis committed Dec 25, 2023
1 parent aa72b0d commit 5168f75
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
9 changes: 7 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM ubuntu

RUN apt-get update \
&& apt-get install -y curl \
&& apt-get install -y amazon-ecr-credential-helper \
curl \
docker \
dotnet-sdk-7.0 \
gh \
git \
jq \
nano \
unzip

RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
Expand All @@ -26,5 +28,8 @@ RUN curl -OJ https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest
&& chmod +x ecs-cli-linux-amd64-latest \
&& mv ecs-cli-linux-amd64-latest /usr/local/bin/ecs-cli

RUN curl -SL https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
RUN docker buildx install

RUN curl -SL https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
RUN chmod +x /usr/local/bin/docker-compose
19 changes: 15 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,31 @@
"context": ".."
},

"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},

"customizations": {
"vscode": {
"extensions": [
"amazonwebservices.aws-toolkit-vscode",
"ms-azuretools.vscode-docker",
"ms-dotnettools.csharp",
"leo-labs.dotnet",
"KishoreIthadi.dotnet-core-essentials",
"4ops.terraform",
"betajob.modulestf",
"hashicorp.hcl",
"HashiCorp.terraform",
"mhutchie.git-graph",
"usernamehw.errorlens"
"usernamehw.errorlens",
"yzhang.markdown-all-in-one"
]
}
},

"postCreateCommand": "dotnet restore"
"mounts": [
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/root/.aws,type=bind",
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/root/.ssh,type=bind"
],

"postCreateCommand": "chmod +x ./bin/setup-cred-helper.sh ; ./bin/setup-cred-helper.sh ; dotnet restore"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,5 @@ Input:
4. run `task deploy`

**To Do**
- [ ] setup dev containers
- [ ] ecs-cli for testing & debugging
- [ ] terraform discord server
13 changes: 2 additions & 11 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ tasks:
- |
commitHash=$(git rev-parse --short HEAD)
ecrUri=$(aws ecr describe-repositories | jq -r '.repositories[] | select( .repositoryName == "pwnctl-exec-short") | .repositoryUri')
docker buildx build --build-arg COMMIT_HASH=$commitHash --ssh default=$SSH_AUTH_SOCK src/core/ -f src/core/pwnctl.exec/shortlived/Dockerfile -t ${ecrUri}:$commitHash
docker build --build-arg COMMIT_HASH=$commitHash --ssh default=$SSH_AUTH_SOCK src/core/ -f src/core/pwnctl.exec/shortlived/Dockerfile -t ${ecrUri}:$commitHash
docker tag ${ecrUri}:$commitHash ${ecrUri}:untested_$commitHash
build-exec-long-image:
cmds:
- |
commitHash=$(git rev-parse --short HEAD)
ecrUri=$(aws ecr describe-repositories | jq -r '.repositories[] | select( .repositoryName == "pwnctl-exec-long") | .repositoryUri')
docker buildx build --build-arg COMMIT_HASH=$commitHash --ssh default=$SSH_AUTH_SOCK src/core/ -f src/core/pwnctl.exec/longlived/Dockerfile -t ${ecrUri}:$commitHash
docker build --build-arg COMMIT_HASH=$commitHash --ssh default=$SSH_AUTH_SOCK src/core/ -f src/core/pwnctl.exec/longlived/Dockerfile -t ${ecrUri}:$commitHash
docker tag ${ecrUri}:$commitHash ${ecrUri}:untested_$commitHash
push-exec-short-image:
Expand All @@ -54,8 +54,6 @@ tasks:
commitHash=$(git rev-parse --short HEAD)
region=$(aws configure get region)
ecrUri=$(aws ecr describe-repositories | jq -r '.repositories[] | select( .repositoryName == "pwnctl-exec-short") | .repositoryUri')
aws ecr get-login-password --region $region \
| docker login --username AWS --password-stdin ${ecrUri}
docker push ${ecrUri}:$commitHash
push-exec-long-image:
Expand All @@ -64,8 +62,6 @@ tasks:
commitHash=$(git rev-parse --short HEAD)
region=$(aws configure get region)
ecrUri=$(aws ecr describe-repositories | jq -r '.repositories[] | select( .repositoryName == "pwnctl-exec-long") | .repositoryUri')
aws ecr get-login-password --region $region \
| docker login --username AWS --password-stdin ${ecrUri}
docker push ${ecrUri}:$commitHash
build-proc-image:
Expand All @@ -82,8 +78,6 @@ tasks:
commitHash=$(git rev-parse --short HEAD)
region=$(aws configure get region)
ecrUri=$(aws ecr describe-repositories | jq -r '.repositories[] | select( .repositoryName == "pwnctl-proc") | .repositoryUri')
aws ecr get-login-password --region $region \
| docker login --username AWS --password-stdin $ecrUri
docker push ${ecrUri}:$commitHash
build-all:
Expand Down Expand Up @@ -123,7 +117,6 @@ tasks:
- |
ecrUri=$(aws ecr describe-repositories | jq -r '.repositories[] | select( .repositoryName == "pwnctl-exec-long") | .repositoryUri')
latestTag=$(docker images | grep $ecrUri | head -n 1 | awk '{print $2}')
aws ecr get-login-password --region $(aws configure get region) | docker login --username AWS --password-stdin $ecrUri
docker run -v ~/.aws/:/root/.aws/ -e PWNCTL_USE_LOCAL_INTEGRATIONS=true \
-e PWNCTL_Logging__FilePath=/mnt/efs -e PWNCTL_Logging__MinLevel=Information \
-e PWNCTL_TaskQueue__VisibilityTimeout=1200 -e PWNCTL_OutputQueue__VisibilityTimeout=1200 \
Expand All @@ -134,7 +127,6 @@ tasks:
- |
ecrUri=$(aws ecr describe-repositories | jq -r '.repositories[] | select( .repositoryName == "pwnctl-exec-short") | .repositoryUri')
latestTag=$(docker images | grep $ecrUri | head -n 1 | awk '{print $2}')
aws ecr get-login-password --region $(aws configure get region) | docker login --username AWS --password-stdin $ecrUri
docker run -e PWNCTL_USE_LOCAL_INTEGRATIONS=true \
-e PWNCTL_Logging__FilePath=/mnt/efs -e PWNCTL_Logging__MinLevel=Information \
-e PWNCTL_TaskQueue__VisibilityTimeout=1200 -e PWNCTL_OutputQueue__VisibilityTimeout=1200 \
Expand All @@ -145,7 +137,6 @@ tasks:
- |
ecrUri=$(aws ecr describe-repositories | jq -r '.repositories[] | select( .repositoryName == "pwnctl-proc") | .repositoryUri')
latestTag=$(docker images | grep $ecrUri | head -n 1 | awk '{print $2}')
aws ecr get-login-password --region $(aws configure get region) | docker login --username AWS --password-stdin $ecrUri
docker run -v ~/.aws/:/root/.aws/ -e PWNCTL_USE_LOCAL_INTEGRATIONS=true \
-e PWNCTL_Logging__FilePath=/mnt/efs -e PWNCTL_Logging__MinLevel=Information \
-e PWNCTL_TaskQueue__VisibilityTimeout=1200 -e PWNCTL_OutputQueue__VisibilityTimeout=1200 \
Expand Down
12 changes: 12 additions & 0 deletions bin/setup-cred-helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

registryId=$(aws ecr describe-registry | jq -r .registryId)
region=$(aws configure get region)

cat >~/.docker/config.json <<EOF
{
"credHelpers": {
"${registryId}.dkr.ecr.${region}.amazonaws.com": "ecr-login"
}
}
EOF

0 comments on commit 5168f75

Please sign in to comment.