Skip to content

Commit

Permalink
fix github build issue (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnusunny authored Aug 17, 2022
1 parent 61bc0ac commit 1ea56b2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
10 changes: 2 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
FROM public.ecr.aws/amazonlinux/amazonlinux:2 as build-stage
ARG TARGET_PLATFORM=linux/amd64
FROM --platform=$TARGET_PLATFORM public.ecr.aws/awsguru/rust-builder as build-stage
ARG ARCH=x86_64
RUN rpm --rebuilddb && yum install -y yum-plugin-ovl jq
RUN yum groupinstall -y "Development tools"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN source $HOME/.cargo/env && rustup target add ${ARCH}-unknown-linux-musl
RUN curl -k -o /${ARCH}-linux-musl-cross.tgz https://musl.cc/${ARCH}-linux-musl-cross.tgz \
&& tar zxf /${ARCH}-linux-musl-cross.tgz \
&& ln -s /${ARCH}-linux-musl-cross/bin/${ARCH}-linux-musl-gcc /usr/local/bin/${ARCH}-unknown-linux-musl-gcc
WORKDIR /app
ADD . /app
RUN source $HOME/.cargo/env &&\
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM public.ecr.aws/amazonlinux/amazonlinux:2 as build-stage
ARG ARCH=x86_64
RUN rpm --rebuilddb && yum install -y yum-plugin-ovl jq
RUN yum groupinstall -y "Development tools"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN source $HOME/.cargo/env && rustup target add ${ARCH}-unknown-linux-musl
RUN curl -k -o /${ARCH}-linux-musl-cross.tgz https://musl.cc/${ARCH}-linux-musl-cross.tgz \
&& tar zxf /${ARCH}-linux-musl-cross.tgz \
&& ln -s /${ARCH}-linux-musl-cross/bin/${ARCH}-linux-musl-gcc /usr/local/bin/${ARCH}-unknown-linux-musl-gcc
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,29 @@ CARGO_PKG_VERSION := $(shell cargo metadata --no-deps --format-version=1 | jq -r
clean:
rm -rf target

build-builder-x86:
DOCKER_BUILDKIT=1 docker build -f Dockerfile.builder --build-arg ARCH=x86_64 -t public.ecr.aws/awsguru/rust-builder:latest-x86_64 .

build-builder-arm64:
DOCKER_BUILDKIT=1 docker build -f Dockerfile.builder --build-arg ARCH=aarch64 -t public.ecr.aws/awsguru/rust-builder:latest-aarch64 .

build-builder: build-builder-x86 build-builder-arm64
docker push public.ecr.aws/awsguru/rust-builder:latest-x86_64
docker push public.ecr.aws/awsguru/rust-builder:latest-aarch64
docker manifest create public.ecr.aws/awsguru/rust-builder:latest \
public.ecr.aws/awsguru/rust-builder:latest-x86_64 \
public.ecr.aws/awsguru/rust-builder:latest-aarch64
docker manifest annotate --arch arm64 public.ecr.aws/awsguru/rust-builder:latest \
public.ecr.aws/awsguru/rust-builder:latest-aarch64

publish-builder:
docker manifest push public.ecr.aws/awsguru/rust-builder:latest

build-x86:
DOCKER_BUILDKIT=1 docker build --build-arg ARCH=x86_64 -t public.ecr.aws/awsguru/aws-lambda-adapter:$(CARGO_PKG_VERSION)-x86_64 .
DOCKER_BUILDKIT=1 docker build --build-arg TARGET_PLATFORM=linux/amd64 --build-arg ARCH=x86_64 -t public.ecr.aws/awsguru/aws-lambda-adapter:$(CARGO_PKG_VERSION)-x86_64 .

build-arm:
DOCKER_BUILDKIT=1 docker build --build-arg ARCH=aarch64 -t public.ecr.aws/awsguru/aws-lambda-adapter:$(CARGO_PKG_VERSION)-aarch64 .
DOCKER_BUILDKIT=1 docker build --build-arg TARGET_PLATFORM=linux/arm64 --build-arg ARCH=aarch64 -t public.ecr.aws/awsguru/aws-lambda-adapter:$(CARGO_PKG_VERSION)-aarch64 .

build: build-x86 build-arm
docker push public.ecr.aws/awsguru/aws-lambda-adapter:$(CARGO_PKG_VERSION)-x86_64
Expand Down

0 comments on commit 1ea56b2

Please sign in to comment.