Skip to content

Commit

Permalink
Use arm64 for switch layer
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed Jun 27, 2024
1 parent 0b0b8a9 commit 832d877
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/switch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
[
{
"identifier": "switch-staging",
"branch": "develop",
"branch": "set_min_buffer_on_mod_twilio_stream",
"image_tag": "staging",
"ecs_service": "switch-staging",
"ecs_cluster": "somleng-switch-staging"
Expand Down Expand Up @@ -135,9 +135,6 @@ jobs:
run: |
components/freeswitch/bin/export_tts_voices > components/freeswitch/conf/autoload_configs/tts_voices.xml
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -161,7 +158,7 @@ jobs:
build-args:
signalwire_token=${{ secrets.SIGNALWIRE_TOKEN }}
push: true
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
cache-from: type=gha,scope=${{ matrix.identifier }}-freeswitch
cache-to: type=gha,mode=max,scope=${{ matrix.identifier }}-freeswitch
tags: |
Expand All @@ -174,7 +171,7 @@ jobs:
with:
context: components/freeswitch_event_logger
push: true
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
cache-from: type=gha,scope=${{ matrix.identifier }}-freeswitch-event-logger
cache-to: type=gha,mode=max,scope=${{ matrix.identifier }}-freeswitch-event-logger
tags: |
Expand All @@ -187,7 +184,7 @@ jobs:
with:
context: components/app
push: true
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
cache-from: type=gha,scope=${{ matrix.identifier }}
cache-to: type=gha,mode=max,scope=${{ matrix.identifier }}
tags: |
Expand Down
8 changes: 5 additions & 3 deletions components/freeswitch/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM public.ecr.aws/debian/debian:bookworm-slim as freeswitch-build
FROM public.ecr.aws/docker/library/debian:bookworm-slim as freeswitch-build
ARG signalwire_token

RUN apt update && apt install --no-install-recommends -yq cmake gcc g++ make cmake build-essential git libssl-dev libspeex-dev libspeexdsp-dev

RUN apt-get update && apt-get install --no-install-recommends -yq gnupg2 wget ca-certificates lsb-release && \
wget --http-user=signalwire --http-password=${signalwire_token} -O /usr/share/keyrings/signalwire-freeswitch-repo.gpg https://freeswitch.signalwire.com/repo/deb/debian-release/signalwire-freeswitch-repo.gpg && \
echo "machine freeswitch.signalwire.com login signalwire password ${signalwire_token}" > /etc/apt/auth.conf && \
chmod 600 /etc/apt/auth.conf && \
echo "deb [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ `lsb_release -sc` main" > /etc/apt/sources.list.d/freeswitch.list && \
echo "deb-src [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ `lsb_release -sc` main" >> /etc/apt/sources.list.d/freeswitch.list && \
apt-get update --allow-releaseinfo-change && \
Expand All @@ -20,15 +21,16 @@ RUN cmake ..
RUN make
RUN make install

FROM public.ecr.aws/aws-cli/aws-cli as aws-cli
FROM public.ecr.aws/aws-cli/aws-cli:latest as aws-cli

FROM public.ecr.aws/debian/debian:bookworm-slim
FROM public.ecr.aws/docker/library/debian:bookworm-slim

ARG signalwire_token

RUN apt-get update && apt-get install --no-install-recommends -yq libssl-dev libspeex-dev libspeexdsp-dev gnupg2 wget ca-certificates lsb-release && \
wget --http-user=signalwire --http-password=${signalwire_token} -O /usr/share/keyrings/signalwire-freeswitch-repo.gpg https://freeswitch.signalwire.com/repo/deb/debian-release/signalwire-freeswitch-repo.gpg && \
echo "machine freeswitch.signalwire.com login signalwire password ${signalwire_token}" > /etc/apt/auth.conf && \
chmod 600 /etc/apt/auth.conf && \
echo "deb [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ `lsb_release -sc` main" > /etc/apt/sources.list.d/freeswitch.list && \
echo "deb-src [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ `lsb_release -sc` main" >> /etc/apt/sources.list.d/freeswitch.list && \
apt-get update --allow-releaseinfo-change && \
Expand Down
8 changes: 4 additions & 4 deletions components/gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# https://apt.opensips.org/packages.php?os=bookworm

FROM public.ecr.aws/debian/debian:bookworm-slim AS bootstrap
FROM public.ecr.aws/docker/library/debian:bookworm-slim AS bootstrap

USER root

ENV DEBIAN_FRONTEND noninteractive

ARG OPENSIPS_VERSION=3.3
ARG OPENSIPS_VERSION=3.4
ARG OPENSIPS_BUILD=releases

RUN apt-get -y update -qq && apt-get -y install gnupg2 ca-certificates curl && \
Expand All @@ -30,13 +30,13 @@ CMD ["create_db"]

# Build

FROM public.ecr.aws/debian/debian:bookworm-slim AS build
FROM public.ecr.aws/docker/library/debian:bookworm-slim AS build

USER root

ENV DEBIAN_FRONTEND noninteractive

ARG OPENSIPS_VERSION=3.3
ARG OPENSIPS_VERSION=3.4
ARG OPENSIPS_BUILD=releases

RUN apt-get -y update -qq && apt-get -y install gnupg2 ca-certificates iproute2 curl netcat-traditional jq && \
Expand Down
2 changes: 1 addition & 1 deletion components/media_proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/debian/debian:bookworm-slim
FROM public.ecr.aws/docker/library/debian:bookworm-slim

USER root

Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ services:
build:
context: components/freeswitch
image: freeswitch:latest
platform: linux/amd64
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
Expand Down Expand Up @@ -128,7 +127,6 @@ services:
build:
context: components/app
image: switch-app:latest
platform: linux/amd64
depends_on:
redis:
condition: service_healthy
Expand Down
22 changes: 11 additions & 11 deletions infrastructure/core/codebuild.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resource "aws_iam_role" "codebuild" {

data "aws_iam_policy_document" "codebuild" {
statement {
effect = "Allow"
effect = "Allow"

resources = [
"arn:aws:logs:*:*:log-group:/aws/codebuild/${local.codebuild_identifier}*",
Expand All @@ -48,7 +48,7 @@ resource "aws_iam_role_policy_attachment" "codebuild_ecr_public" {
}

resource "aws_codebuild_project" "amd64" {
name = "${local.codebuild_identifier}-amd64"
name = "${local.codebuild_identifier}-amd64"

service_role = aws_iam_role.codebuild.arn

Expand All @@ -62,20 +62,20 @@ resource "aws_codebuild_project" "amd64" {
}

environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/amazonlinux2-x86_64-standard:5.0"
type = "LINUX_CONTAINER"
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/amazonlinux2-x86_64-standard:5.0"
type = "LINUX_CONTAINER"
privileged_mode = true
}

source {
type = "GITHUB"
type = "GITHUB"
location = "https://github.com/somleng/somleng-switch.git"
}
}

resource "aws_codebuild_project" "arm64" {
name = "${local.codebuild_identifier}-arm64"
name = "${local.codebuild_identifier}-arm64"

service_role = aws_iam_role.codebuild.arn

Expand All @@ -89,14 +89,14 @@ resource "aws_codebuild_project" "arm64" {
}

environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/amazonlinux2-aarch64-standard:3.0"
type = "ARM_CONTAINER"
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/amazonlinux2-aarch64-standard:3.0"
type = "ARM_CONTAINER"
privileged_mode = true
}

source {
type = "GITHUB"
type = "GITHUB"
location = "https://github.com/somleng/somleng-switch.git"
}
}
2 changes: 2 additions & 0 deletions infrastructure/modules/somleng_switch/switch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module "switch_container_instances" {

app_identifier = var.switch_identifier
vpc = var.vpc
architecture = "arm64"
instance_type = "t4g.small"
instance_subnets = var.vpc.private_subnets
cluster_name = aws_ecs_cluster.cluster.name
max_capacity = var.switch_max_tasks * 2
Expand Down

0 comments on commit 832d877

Please sign in to comment.