Last active
February 13, 2024 13:32
-
-
Save gmoon/3800dd80498d242c4c6137860fe410fd to your computer and use it in GitHub Desktop.
Dockerfile for aws-cli, aws-sam-cli, and python3 on alpine linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.10 | |
RUN apk -v --no-cache --update add \ | |
musl-dev \ | |
gcc \ | |
python3 \ | |
python3-dev | |
RUN python3 -m ensurepip --upgrade \ | |
&& pip3 install --upgrade pip | |
RUN pip3 install --upgrade awscli aws-sam-cli | |
RUN pip3 uninstall --yes pip \ | |
&& apk del python3-dev gcc musl-dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the commands, saved me a lot of time. In return, here is a small optimization suggestion:
The line 10 & 11 doesn't actually help the size of the image as the previous layers still keep the packages. To gain slimming benefits all of it needs to be in one line, like this:
RUN apk --quiet --no-cache --no-progress --update add
musl-dev gcc python3 python3-dev libffi-dev bash
&& python3 -m ensurepip --upgrade
&& pip3 install --upgrade pip awscli aws-sam-cli
&& apk del python3-dev gcc musl-dev libffi-dev
The difference is about 160 megabytes.