diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..699c09d04 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +node_modules/ +dist +build + +.git +.gitignore + +public +lambda +docs +emails + +docker +docker-compose.yml +Dockerfile + +views \ No newline at end of file diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 51e60d96e..5e36167f1 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -10,6 +10,8 @@ on: jobs: build: + if: github.repository == 'dekkerglen/CubeCobra' + runs-on: ubuntu-latest timeout-minutes: 30 diff --git a/.github/workflows/image-push.yml b/.github/workflows/image-push.yml new file mode 100644 index 000000000..5748a5fea --- /dev/null +++ b/.github/workflows/image-push.yml @@ -0,0 +1,58 @@ +name: Build and Push Docker Image to ECR + +permissions: + contents: read + id-token: write + +on: + push: + branches: + - master + +jobs: + build-and-push: + if: github.repository == 'dekkerglen/CubeCobra' + name: Build and Push to ECR + runs-on: ubuntu-latest + + strategy: + matrix: + target: + - environment: development + stack: CubeCobraDevStack + - environment: production + stack: CubeCobraProdStack + + env: + role: ${{ secrets.CDK_IAM_ROLE }} + region: us-east-2 + + environment: ${{ matrix.target }} + + steps: + - uses: actions/checkout@v4 + + - uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ env.role }} + aws-region: ${{ env.region }} + + - name: Get ECR Repository Name from CDK Stack + env: + STACK_NAME: ${{ matrix.target.environment }} + run: | + ECR_REPO_NAME=$(aws cloudformation describe-stacks \ + --stack-name ${STACK_NAME} \ + --query "Stacks[0].Outputs[?OutputKey=='EcrRepositoryName'].OutputValue" \ + --output text) + + echo "ECR_REPO_NAME=${ECR_REPO_NAME}" >> $GITHUB_ENV + + - id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - env: + REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + docker build -t $REGISTRY/$ECR_REPO_NAME:latest . + docker push $REGISTRY/$ECR_REPO_NAME:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..e55c0f7e2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:20.18.0 + +WORKDIR "/app" + +COPY package*.json ./ + +RUN npm install + +COPY . . + +CMD ["echo", "hello, world"] \ No newline at end of file