-
Notifications
You must be signed in to change notification settings - Fork 6
4. More on Docker
There are a few options currently available when it comes to Docker images.
-
Dockerfile.x86
builds an x86 image from scratch -
Dockerfile.arm
builds an arm image from scratch -
Dockerfile.scratch
dockerizes a prebuilt binary (you need to specify the path but it defaults to the x86 release one)
Notice that all of them build for release. If you want to build for AWS Lambda, you need to specify --build-arg compile_flag="--features aws-lambda"
.
Note
As it stands right now, the dockerfile expects a feeds.txt
file to be there instead of using environment variables for the feeds.
The x86 one is pretty straightforward, you can just run
docker build -f Dockerfile.x86 .
# Or if you want to build for AWS Lambda
docker build -f Dockerfile.x86 --build-arg compile_flag="--features aws-lambda" .
This is built every time in the "Build and Tests" workflow task so it should always work just fine.
The arm one is trickier.
While the Dockerfile does work, it takes way too long and I am not too sure why, I would assume it needs a lot more Ram for some reason. I haven't really built images for arm before so I probably did something very stupid, definitely open to community contributions for this one!
This is why I've also created the Dockerfile.scratch
file as building the binary natively is a lot faster.
I won't go into too much detail here since, if you are reading this, you probably know way more than I do on the topic so I'll instead show how I build the image in the pipeline.
rustup target add aarch64-unknown-linux-musl
pip3 install ziglang
cargo install cargo-zigbuild
cargo zigbuild --release --target aarch64-unknown-linux-musl
# or
cargo zigbuild --release --features aws-lambda --target aarch64-unknown-linux-musl
docker build -f Dockerfile.scratch --build-arg path="./target/aarch64-unknown-linux-musl/release/rss2email" .
I definitely recommend using the scratch
approach as the other one is not even tested anymore.