Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 44 additions & 25 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye

RUN sudo apt-get update -y \
&& sudo apt-get upgrade -y

RUN sudo apt-get install -y --fix-missing zip

RUN sudo apt-get update -y \
&& sudo apt-get upgrade -y \
&& sudo apt-get install -y zip ltrace

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN rustup update \
&& rustup target add aarch64-unknown-linux-gnu

RUN rustup default stable
# x86_64 to arm64 support.
RUN sudo apt-get install -y \
qemu \
FROM mcr.microsoft.com/devcontainers/rust:1-1-bookworm

RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install -y --fix-missing --no-install-recommends \
\
# Zip for packaging
zip \
\
# QEMU for multi-architecture support
qemu-system \
binfmt-support \
qemu-user-static
qemu-user-static \
\
# Language runtimes for tests
nodejs \
ruby \
php \
php-common \
python3-pip \
\
# Cross-compilation toolchains
gcc-x86-64-linux-gnu \
libc6-dev-amd64-cross \
gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross \
\
# Clean up, enable QEMU, and set Python alternative in a single layer
&& rm -rf /var/lib/apt/lists/* \
&& update-binfmts --enable qemu-aarch64 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 1

# Switch to root to install rust targets and fix permissions
USER root

# Install rust targets for cross-compilation
RUN rustup update \
&& rustup default stable \
&& rustup target add aarch64-unknown-linux-gnu \
&& rustup target add x86_64-unknown-linux-gnu

# Easy way to install node, ruby, and php
RUN apt-get -y install nodejs ruby php php-common
# Grant vscode user ownership of rustup and cargo directories
RUN chown -R vscode:vscode /usr/local/rustup /usr/local/cargo

# Easy way to install Python.
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
# Switch back to vscode user
USER vscode

# Multi-platform SAM CLI. https://github.com/aws/aws-sam-cli/issues/3908
RUN apt-get install -y pip && pip install aws-sam-cli
RUN pip install aws-sam-cli --break-system-packages
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
},
"features": {
"ghcr.io/devcontainers/features/aws-cli:latest": {},
"ghcr.io/devcontainers/features/docker-in-docker:latest": {},
"ghcr.io/devcontainers/features/docker-in-docker:latest": {
"install-qemu": false
},
"ghcr.io/customink/codespaces-features/docker-log-level": {},
"ghcr.io/devcontainers/features/sshd:latest": {}
},
Expand Down
16 changes: 11 additions & 5 deletions .devcontainer/postCreate
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/bin/sh
set -e

docker run \
--rm \
--privileged \
multiarch/qemu-user-static \
--reset -p yes
# Wait for docker to be ready
TIMEOUT=30
while ! docker info > /dev/null 2>&1; do
echo "Waiting for docker daemon..."
sleep 1
TIMEOUT=$((TIMEOUT - 1))
if [ $TIMEOUT -le 0 ]; then
echo "Docker daemon failed to start"
exit 1
fi
done
54 changes: 48 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, workflow_dispatch]
jobs:
image:
name: Image
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v2
Expand All @@ -19,7 +19,7 @@ jobs:
runCmd: echo DONE!
debian-x86-64:
name: Debian x86_64
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: image
steps:
- name: Checkout
Expand All @@ -34,11 +34,15 @@ jobs:
./bin/test-local
debian-arm64:
name: Debian arm64
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: image
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test
uses: devcontainers/ci@v0.2
with:
Expand All @@ -49,7 +53,7 @@ jobs:
./debian/test-arm64
amazon-x86-64:
name: AmazonLinux2/x86_64
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: image
steps:
- name: Checkout
Expand All @@ -64,11 +68,15 @@ jobs:
./amzn/test
amazon-arm64:
name: AmazonLinux2 arm64
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: image
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test
uses: devcontainers/ci@v0.2
with:
Expand All @@ -79,7 +87,7 @@ jobs:
./amzn/test-arm64
ubuntu-py27:
name: Ubuntu x86_64 (Python27)
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: image
steps:
- name: Checkout
Expand All @@ -92,3 +100,37 @@ jobs:
runCmd: |
./py27/setup
./py27/test
amazonlinux2023-x86-64:
name: AmazonLinux2023/x86_64
runs-on: ubuntu-22.04
needs: image
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test
uses: devcontainers/ci@v0.2
with:
push: never
cacheFrom: ghcr.io/rails-lambda/crypteia-ci
runCmd: |
./amzn2023/setup
./amzn2023/test
amazonlinux2023-arm64:
name: AmazonLinux2023 arm64
runs-on: ubuntu-22.04
needs: image
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test
uses: devcontainers/ci@v0.2
with:
push: never
cacheFrom: ghcr.io/rails-lambda/crypteia-ci
runCmd: |
./amzn2023/setup-arm64
./amzn2023/test-arm64
19 changes: 19 additions & 0 deletions amzn2023/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM public.ecr.aws/amazonlinux/amazonlinux:2023

# Install required build dependencies and Node.js for testing
RUN dnf install -y gcc openssl-devel python3-pip util-linux nodejs && \
pip3 install setuptools && \
dnf clean all

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

RUN /root/.cargo/bin/rustup update \
&& /root/.cargo/bin/rustup target add aarch64-unknown-linux-gnu \
&& /root/.cargo/bin/rustup default stable

WORKDIR /var/task

ENV CRYPTEIA_BUILD_OS=amzn
ENV CRYPTEIA_BUILD_TARGET=x86_64-unknown-linux-gnu

18 changes: 18 additions & 0 deletions amzn2023/Dockerfile-arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM public.ecr.aws/amazonlinux/amazonlinux:2023

# Install required build dependencies and Node.js for testing
RUN dnf install -y gcc openssl-devel python3-pip util-linux nodejs && \
pip3 install setuptools && \
dnf clean all

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

RUN /root/.cargo/bin/rustup update \
&& /root/.cargo/bin/rustup target add aarch64-unknown-linux-gnu \
&& /root/.cargo/bin/rustup default stable

WORKDIR /var/task

ENV CRYPTEIA_BUILD_OS=amzn
ENV CRYPTEIA_BUILD_TARGET=aarch64-unknown-linux-gnu
15 changes: 15 additions & 0 deletions amzn2023/Dockerfile-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM public.ecr.aws/lambda/nodejs:22

COPY build/crypteia-amzn /opt/extensions/crypteia
COPY build/libcrypteia-amzn.so /opt/lib/libcrypteia.so

WORKDIR /var/task

ENV CRYPTEIA_BUILD_OS=amzn
ENV SKIP_CARGO_TEST=1

ENV EXISTING=existingvalue
ENV LD_PRELOAD=/opt/lib/libcrypteia.so

# For assert.sh support
RUN dnf install -y util-linux && dnf clean all
16 changes: 16 additions & 0 deletions amzn2023/Dockerfile-test-arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM public.ecr.aws/lambda/nodejs:22-arm64

COPY build/crypteia-amzn-arm64 /opt/extensions/crypteia
COPY build/libcrypteia-amzn-arm64.so /opt/lib/libcrypteia.so

WORKDIR /var/task

ENV CRYPTEIA_BUILD_OS=amzn
ENV SKIP_CARGO_TEST=1

ENV EXISTING=existingvalue
ENV LD_PRELOAD=/opt/lib/libcrypteia.so

# For assert.sh support
RUN dnf install -y util-linux && dnf clean all

14 changes: 14 additions & 0 deletions amzn2023/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -e

echo "== [amzn2023/Dockerfile] building... =="
docker build --tag crypteia-lambda-amzn2023 --file amzn2023/Dockerfile .

echo "== [amzn2023/Dockerfile] bin/setup =="
docker run \
--rm \
--user root \
--entrypoint "./bin/setup" \
--volume "${PWD}:/var/task" \
crypteia-lambda-amzn2023

14 changes: 14 additions & 0 deletions amzn2023/setup-arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -e

echo "== [amzn2023/Dockerfile-arm64] building... =="
docker build --platform linux/arm64 --tag crypteia-lambda-amzn2023-arm64 --file amzn2023/Dockerfile-arm64 .

echo "== [amzn2023/Dockerfile-arm64] bin/setup =="
docker run \
--platform linux/arm64 \
--rm \
--user root \
--entrypoint "./bin/setup" \
--volume "${PWD}:/var/task" \
crypteia-lambda-amzn2023-arm64
24 changes: 24 additions & 0 deletions amzn2023/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
set -e

echo "== [amzn2023/Dockerfile] bin/test =="
docker run \
--rm \
--user root \
--entrypoint "./test/libcrypteia.sh" \
--volume "${PWD}:/var/task" \
--env TEST_LANG=node \
crypteia-lambda-amzn2023

echo "== [amzn2023/Dockerfile-test] lambda/runtime building... =="
docker build --tag crypteia-lambda-amzn2023-test --file amzn2023/Dockerfile-test .

echo "== [amzn2023/Dockerfile-test] lambda/runtime bin/test =="
docker run \
--rm \
--user root \
--entrypoint "./test/libcrypteia.sh" \
--volume "${PWD}:/var/task" \
--env TEST_LANG=node \
crypteia-lambda-amzn2023-test

24 changes: 24 additions & 0 deletions amzn2023/test-arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
set -e

echo "== [amzn2023/Dockerfile-arm64] bin/test =="
docker run \
--rm \
--user root \
--entrypoint "./test/libcrypteia.sh" \
--volume "${PWD}:/var/task" \
--env TEST_LANG=node \
--platform=linux/arm64 \
crypteia-lambda-amzn2023-arm64

echo "== [amzn2023/Dockerfile-test-arm64] lambda/runtime building... =="
docker build --tag crypteia-lambda-amzn2023-test-arm64 --file amzn2023/Dockerfile-test-arm64 .

echo "== [amzn2023/Dockerfile-test-arm64] lambda/runtime bin/test =="
docker run \
--rm \
--user root \
--entrypoint "./test/libcrypteia.sh" \
--volume "${PWD}:/var/task" \
--env TEST_LANG=node \
crypteia-lambda-amzn2023-test-arm64
18 changes: 17 additions & 1 deletion bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@ set -e

# Sync with bin/build, bin/test, & test/libcrypteia.sh.
export CRYPTEIA_BUILD_OS="${CRYPTEIA_BUILD_OS:=debian}"
export CRYPTEIA_BUILD_TARGET="${CRYPTEIA_BUILD_TARGET:=x86_64-unknown-linux-gnu}"

# Auto-detect build target if not already set
if [ -z "${CRYPTEIA_BUILD_TARGET}" ]; then
case "$(uname -m)" in
aarch64)
export CRYPTEIA_BUILD_TARGET="aarch64-unknown-linux-gnu"
;;
x86_64)
export CRYPTEIA_BUILD_TARGET="x86_64-unknown-linux-gnu"
;;
*)
echo "Unsupported architecture: $(uname -m)"
exit 1
;;
esac
fi

if [ "${CRYPTEIA_BUILD_TARGET}" = "aarch64-unknown-linux-gnu" ]; then
export CRYPTEIA_BUILD_SUFFIX="-arm64"
fi
Expand Down
Loading