Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ on:
pull_request:
push:
branches: [ "main" ]
# Only files that end up in the image republish it. Pull requests stay
# unfiltered so the required "build" check always reports.
paths:
- 'Dockerfile'
- 'script.sh'
- 'mfa.sh'
- 'aws-role-credentials'
- 'aws-mfa-session'
- '.github/workflows/docker-build-push.yml'
tags:
- 'prod-*'
env:
Expand Down
23 changes: 23 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,34 @@ function dev() {
docker_cmd+=" -e PORTUNUS_TOKEN=${PORTUNUS_TOKEN}/$1"
fi

# Name the container dev-<project>-<stage> (or dev-<dirname>) so it can be found with docker ps / docker exec
local base name n=1
if [ "$#" -eq 1 ]; then
base="dev-${1%%/*}-${1#*/}"
else
base="dev-$(basename "$PWD")"
fi
base=${base//[^a-zA-Z0-9_.-]/-}
name=$base
while sudo docker ps --format '{{.Names}}' | grep -qx "$name"; do n=$((n+1)); name="$base-$n"; done
docker_cmd+=" --name $name --hostname $name"

docker_cmd+=" --entrypoint /script.sh ashishjullia19/docker-dev-env"
eval $docker_cmd
}
```

## Container names

Each container is named `dev-<project>-<stage>` (or `dev-<dirname>` when run without a project). If that name is already running, `-2`, `-3` and so on are added. The name is also the hostname, so the shell prompt shows which container you are in.

```bash
docker ps --filter name=dev-
docker exec -it <name> /script.sh
```

A plain `docker exec -it <name> bash` does not see the Portunus variables, because `script.sh` exports them only into the shell it starts. Run `/script.sh` through `docker exec` to get the same environment. It asks for the MFA code again when the project has `AWS_MFA_SERIAL`.

## With portunus integration:

For `PORTUNUS_TOKEN` make sure to grab this from portunus ui `portunus.ashishjullia.com` and you'll get the token in format:
Expand Down
Loading