diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea04f94..670b154 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,17 +82,10 @@ jobs: build_docker_multi_arch: needs: create_infrastructure runs-on: ubuntu-latest - if: github.event_name != 'pull_request' steps: - name: checkout uses: actions/checkout@v4 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::246770851643:role/github-actions - aws-region: us-east-1 - - name: Set up Python 3.11 uses: actions/setup-python@v5 with: @@ -104,6 +97,18 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::246770851643:role/github-actions + aws-region: us-east-1 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v2 @@ -129,9 +134,25 @@ jobs: - name: export requirements run: poetry export -f requirements.txt -o requirements.txt --without-hashes + - name: Docker meta + id: meta-dockerhub + uses: docker/metadata-action@v5 + with: + images: tobiaswaslowski/mood-tracker + flavor: | + latest=true + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha - name: Docker meta - id: meta + id: meta-ecr uses: docker/metadata-action@v5 with: images: public.ecr.aws/c1o1h8f4/mood-tracker @@ -147,13 +168,25 @@ jobs: type=semver,pattern={{major}} type=sha + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta-dockerhub.outputs.tags }} + labels: ${{ steps.meta-dockerhub.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + - name: Build and push uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta-ecr.outputs.tags }} + labels: ${{ steps.meta-ecr.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/README.md b/README.md index 727324d..de728bd 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Assuming you have a MongoDB instance running on your local machine that is bound (e.g. by running `docker run -p 27017:27017 mongo`) you can run the following command: docker run --env TELEGRAM_TOKEN=$TELEGRAM_TOKEN \ - public.ecr.aws/c1o1h8f4/mood-tracker:latest + tobiaswaslowski/mood-tracker:latest Supported architectures are x86_64 (amd64) and arm64. If you require images for additional architectures, feel free to raise a ticket or build your own images (see [Development](#development)). @@ -97,7 +97,7 @@ The run command in that case could look like this: docker run --env TELEGRAM_TOKEN=$TELEGRAM_TOKEN \ --env MONGO_HOST=192.168.1.1:27017 \ --network="host" \ - public.ecr.aws/c1o1h8f4/mood-tracker:latest + tobiaswaslowski/mood-tracker:latest For more guidance on Docker networking, please refer to the [official documentation](https://docs.docker.com/network/). @@ -116,7 +116,7 @@ docker run -d --rm \ --name mood-tracker \ -e TELEGRAM_TOKEN="$TELEGRAM_TOKEN" \ -v "$HOME/.aws/credentials:/root/.aws/credentials:ro" \ - public.ecr.aws/c1o1h8f4/mood-tracker:latest + tobiaswaslowski/mood-tracker:latest ``` Why `/root/.aws/credentials`? Because `boto3` checks in the home directory of the user running the script for the @@ -134,7 +134,7 @@ docker run -d --rm \ --name mood-tracker \ -e TELEGRAM_TOKEN="$TELEGRAM_TOKEN" \ -v ./config.yaml:/app/config.yaml \ - public.ecr.aws/c1o1h8f4/mood-tracker:latest + tobiaswaslowski/mood-tracker:latest ``` # Configuration diff --git a/docker-compose.yml b/docker-compose.yml index 6c48239..87443e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: - mongo_data:/data/db mood-tracker: - image: public.ecr.aws/c1o1h8f4/mood-tracker:latest + image: tobiaswaslowski/mood-tracker:latest build: context: . dockerfile: Dockerfile diff --git a/scripts/run.sh b/scripts/run.sh index 4c44d0e..ca670f3 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -18,4 +18,4 @@ sudo docker run -d --rm \ --security-opt seccomp:unconfined \ -v "$HOME/.aws/credentials:/root/.aws/credentials:ro" \ -v ./config.yaml:/app/config.yaml \ - public.ecr.aws/c1o1h8f4/mood-tracker:latest + tobiaswaslowski/mood-tracker:latest diff --git a/terraform/files/USAGE.md b/terraform/files/USAGE.md index 72984ba..3913b75 100644 --- a/terraform/files/USAGE.md +++ b/terraform/files/USAGE.md @@ -1,28 +1,19 @@ # Usage +## DEPRECATION NOTICE + +I'm discontinuing support for ECR. Please use the Docker Hub image instead. The new repository is: + + tobiaswaslowski/mood-tracker + ## Quickstart -I host the Docker image for this application on a public ECR repository. You have to create your own -Telegram via the [Botfather](https://t.me/botfather) and supply it to the container as an environment variable. +You have to create your ownm Telegram via the [Botfather](https://t.me/botfather) and supply it to the container as an environment variable. Additionally, you'll have to have a MongoDB instance running for persistence. Assuming you have a MongoDB instance running on your local machine that is bound to `127.0.0.1:27017`, (e.g. by running `docker run -p 27017:27017 mongo`) you can run the following command: docker run --env TELEGRAM_TOKEN=$TELEGRAM_TOKEN \ - public.ecr.aws/c1o1h8f4/mood-tracker:latest - -Supported architectures are x86_64 (amd64) and arm64. If you require images -for additional architectures, feel free to raise a ticket or build your own images (see [Development](#development)). - -## MongoDB Configuration - -If your MongoDB instance is bound to a different hosts, you'll have to supply the connection string as an environment -variable. If you're running Docker for Linux, I recommend using `--network="host"` for simplicity's sake. -The run command in that case could look like this: - - docker run --env TELEGRAM_TOKEN=$TELEGRAM_TOKEN \ - --env MONGO_HOST=192.168.1.1:27017 \ - --network="host" \ - public.ecr.aws/c1o1h8f4/mood-tracker:latest + tobiaswaslowski/mood-tracker:latest -For more guidance on Docker networking, please refer to the [official documentation](https://docs.docker.com/network/). +DynamoDB is also supported as a backend. For more information, check out the [documentation](https://github.com/twaslowski/telegram-mood-tracker?tab=readme-ov-file#running).