mirage-ecs is reverse proxy for ECS task and task manager.
mirage-ecs can run and stop ECS task and serve http request with specified subdomain. Additionaly, mirage passes variable to containers in task using environment variables.
- Setup mirage-ecs and edit configuration (see Setup section for detail.)
- Run mirage-ecs on ECS cluster.
Following instructions use below settings.
host:
webapi: docker.dev.example.net
reverse_proxy_suffix: .dev.example.net
listen:
HTTP: 80
Prerequisite: you should resolve *.dev.example.net to your ECS task.
mirage-ecs requires ECS Long ARN Format for tagging tasks.
If your account do not enable these settings yet, you must enable that.
$ aws ecs put-account-setting-default --name taskLongArnFormat --value enabled- Launch ECS task container using curl.
curl http://docker.dev.example.net/api/launch \
-d subdomain=cool-feature \
-d branch=feature/cool \
-d taskdef=myapp
-
Now, you can access to container using "http://cool-feature.dev.exmaple.net/".
-
Terminate the task using curl.
curl http://docker.dev.example.net/api/terminate \
-d subdomain=cool-feature
subdomain supports wildcard (e.g. www*,foo[0-9], api-?-test).
Mirage matches the pattern to hostname using Go's path/#Match.
- Access to mirage web interface via "http://docker.dev.example.net/".
- Press "Launch New Task".
- Fill launch options.
- subdomain: cool-feature
- branch: feature/cool
- taskdef: myapp
- Now, you can access to container using "http://cool-feature.dev.exmaple.net/".
- Press "Terminate" button.
mirage-ecs now supports custom parameter. Write your parameter on config.yml.
mirage-ecs contains default parameter "branch" as below.
parameters:
- name: branch
env: GIT_BRANCH
rule: ""
required: true
You can add custom parameter. "rule" option is regexp string.
In docker/ directory,
- Edit
config.ymlto your environment. - Do
maketo create a docker image. - Push the image to ECR.
- Put mirage-ecs task definition to ECS.
- See also mirage-ecs-taskdef.json
- Run mirage-ecs service in your ECS.
The MIT License (MIT)
(c) 2019 acidlemon. (c) 2019 KAYAC Inc. (c) 2019 fujiwara.