A dave Docker setup for AWS Elastic Container Service, as well as Terraform to provision infrastructure.
- clone the repo
- rename
server/config.example.yaml👉config.yaml - adjust the values to your liking
- create certificates for TLS by following the
daveREADME or comment out thetlssection - use the
davecli to generate passwords forserver/config.example.yamlrunningcd server && go run cmd/davecli/main.go passwd- you may need to install
gofirst
- you may need to install
- adjust paths in
server/Dockerfileto suit your needs
I use pass to manage secrets and inject them when running Docker and Terraform commands. You can set this up yourself, or set the values in plaintext in the tf/scripts/set-tf-vars.example.sh script.
- rename
tf/scripts/set-tf-vars.example.sh👉set-tf-vars.sh- ensure this file is executable by running
chmod a+x tf/scripts/set-tf-vars.sh
- ensure this file is executable by running
- use whatever domain/subdomain your heart desires
- note: at the time of writing, this setup requires a subdomain
- run
make tfito initialize Terraform- if enabling s3 backend, you'll be asked for the bucket name, key, and region - name must be
webdav-stateunless you'd like to adjust its value invars.tf
- if enabling s3 backend, you'll be asked for the bucket name, key, and region - name must be
- As with Terraform, secrets are injected via
passby default. You can set uppass, or set the variables at the top ofMakefilein plaintext.
First, we need to set up the ECR repository. We'll run make tfa and answer "yes" to the prompt. This will provision everything but the ECS Cluster, Service, and Task. We need to build and deploy the Docker image to ECR first. Follow the steps below.
Important: Note that the Makefile uses docker buildx build and a target architecture of linux/amd64. This builds Docker images for AWS ECS on M1/M2 Macs, which default to building with the Apple silicon ARM architecture.
- if you haven't already, run
make tfito initialize Terraform - run
make tfato provision your infrastructure- note: as mentioned above, the first run will yield no ECS Cluster, Service, or Tasks — because the ECR repository is currently empty... we'll fix that in the next section.
First, be sure to set your ECR_URI variable in Makefile now that the AWS ECR repo is set up.
- run
make db, which will build the Docker image and name the target what is specified in theIMAGE_NAMEvariable at the top ofMakefile - run
make dp, which will login to AWS, tag the image with build time and "latest", and push it to the ECR repo set viaECR_URIat the top ofMakefile - check the AWS Console to ensure your image has been pushed
- be sure you are in the region specified in
Makefileandtf/scripts/set-tf-vars.sh
- be sure you are in the region specified in
- modify
tf/modules/cluster/cluster.tfas such:- uncomment lines 32-35
- this section will pull the latest image digest
- comment line 41
- uncomment line 44
- this will attach the latest image digest to your ECS Cluster Task Definition, which will recreate the resource any time a new version of the image is found
- uncomment lines 32-35
- run
make tfionce more if you've changed anything since the first steps in this README - run
make tfpto check what actions Terraform will be performing - run
make tfa - when prompted, type
yes, and hit "Enter/Return" - celebrate
Note: As this is a WebDAV server, there is nothing to open in the browser. You can check if your users/passwords are working by going to https://subdomain.example.net, but the browser won't know what to do after you authenticate.
Connectivity can be checked in macos by using Finder:
- open a Finder window
- hit cmd+k
- type
https://subdomain.example.comand click "Connect" - you will be prompted for user/pass (these are what was set up in
server/config/config.yaml)
The Makefile includes useful short commands that apply the project variables you've set in the Getting Started section.
Heavily based on Micromata's WebDAV server dave. A HUGE thank you! 🙇♂️