diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..8a9e036 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,43 @@ +name: Build and Deploy to AWS ECR + +on: + push: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v1 + with: + mask-password: true + + - name: Build, Tag, and Push Docker image to ECR + run: | + docker build -t clearsettleengine . + docker tag counter_web 211125762589.dkr.ecr.us-west-2.amazonaws.com/repo:clearsettleengine + docker push 211125762589.dkr.ecr.us-west-2.amazonaws.com/repo:clearsettleengine + env: + AWS_DEFAULT_REGION: us-west-2 + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + - name: Trigger Deployment + uses: peter-evans/repository-dispatch@v1 + with: + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + repository: tim-br/counter_k8s + event-type: deploy-clearsettleengine-event \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..af9bff1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# Use an official Elixir runtime as a parent image +FROM elixir:latest + +# Create and set the working directory +WORKDIR /app + +# Copy the mix.exs and mix.lock files to the container +COPY mix.exs mix.lock ./ + +# Install hex and rebar + +RUN mix archive.install github hexpm/hex branch latest --force + +RUN mix local.rebar --force +# Install dependencies +RUN mix deps.get + +# Copy the rest of your application's code +COPY . . + +# Compile the project + +RUN mix do compile + +# Run the application +CMD ["mix", "run"]