Skip to content

Commit

Permalink
runtime container
Browse files Browse the repository at this point in the history
  • Loading branch information
omerh committed Jan 28, 2024
1 parent 31f5469 commit 0b27947
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/guardian-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,22 @@ jobs:
- name: Login to ECR
run: $(aws ecr get-login --no-include-email --region ${{ env.AWS_REGION }}) > /dev/null

- name: Build and push
- name: Build and push getting started container
uses: docker/build-push-action@v5
with:
file: Dockerfile_whatsappmulti_getting_started
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.AWS_ACCOUNT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ github.event.repository.name }}:${{ env.BRANCH_NAME }}
${{ env.AWS_ACCOUNT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ github.event.repository.name }}:getting_started
${{ env.AWS_ACCOUNT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ github.event.repository.name }}:getting_started
- name: Build and push runtime container
uses: docker/build-push-action@v5
with:
file: Dockerfile_whatsappmulti_runtime
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.AWS_ACCOUNT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ github.event.repository.name }}:runtime-${{ github.run_number }}
${{ env.AWS_ACCOUNT }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ github.event.repository.name }}:runtime
18 changes: 18 additions & 0 deletions Dockerfile_whatsappmulti_runtime
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM alpine AS builder

COPY . /go/src/matterbridge
RUN apk --no-cache add go git \
&& cd /go/src/matterbridge \
&& CGO_ENABLED=0 go build -tags whatsappmulti,nomsteams,nozulip -mod vendor -ldflags "-X github.com/42wim/matterbridge/version.GitHash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge

FROM alpine
RUN apk --no-cache add ca-certificates mailcap aws-cli openssl

RUN mkdir /etc/matterbridge
WORKDIR /etc/matterbridge

COPY --from=builder /bin/matterbridge /etc/matterbridge/
COPY --from=builder /go/src/matterbridge/run.sh /etc/matterbridge/

ENTRYPOINT [ "sh", "run.sh" ]
CMD ["/etc/matterbridge/matterbridge"]
35 changes: 35 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
#
# Matterbridge runtime
#
# set -x
# Environment variables:
# phoneNumber e.g 972505152183
# userStorage e.g. s3://us-west-2-guardian-data154316-dev/private/us-west-2:6da317cd-7edd-472d-8d3c-6aee1296ac3c/phone-data/${phoneNumber}/

# files
phoneNumber="972525583454"
CONF_FILE="matterbridge.toml"
SESSION_FILE="session+${phoneNumber}.gob.db"
FILE_DESTINATION="/etc/matterbridge/"
userStorage="s3://us-west-2-guardian-data154316-dev/private/us-west-2:6da317cd-7edd-472d-8d3c-6aee1296ac3c/phone-data/${phoneNumber}"

# download from S3
donwload_from_s3() {
echo "Downloading $1 to ${userStorage}"
aws s3 cp --profile c $userStorage/$1 $FILE_DESTINATION/$1
}

# environment debug
echo "working on phoneNumber: $phoneNumber"
echo "bucket: $userStorage"
echo "session file: ${SESSION_FILE}"

# Download config, and session db file from s3 userStorage
donwload_from_s3 ${CONF_FILE}
download_from_s3 ${SESSION_FILE}

echo "Starting matterbrigde"
# /etc/matterbridge/matterbridge
exec "$@"

0 comments on commit 0b27947

Please sign in to comment.