Optimized docker image size, added ":latest" tag to Makefile docker build commands
This commit is contained in:
parent
8e6b0a39b2
commit
2135126235
2 changed files with 15 additions and 5 deletions
14
Dockerfile
14
Dockerfile
|
@ -1,7 +1,15 @@
|
||||||
FROM python:3-alpine
|
FROM alpine:latest as build
|
||||||
RUN apk update && apk upgrade && apk add py-pip make
|
RUN apk add --no-cache python3 python3-dev py3-pip mariadb-dev build-base
|
||||||
|
RUN pip install --no-cache-dir wheel
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN pip install -r requirements.txt
|
RUN pip wheel --no-cache-dir -w /app/wheels -r requirements.txt
|
||||||
|
|
||||||
|
FROM alpine:latest as run
|
||||||
|
RUN apk add --no-cache python3 py3-pip make mariadb-connector-c-dev
|
||||||
|
COPY --from=build /app /app
|
||||||
|
WORKDIR /app
|
||||||
|
RUN pip install --no-cache-dir --find-links /app/wheels -r requirements.txt
|
||||||
|
RUN apk del py3-pip && rm -rf /app/wheels
|
||||||
CMD make prod
|
CMD make prod
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -31,7 +31,9 @@ clean:
|
||||||
rm -rf .mypy_cache
|
rm -rf .mypy_cache
|
||||||
|
|
||||||
cmd-docker-build:
|
cmd-docker-build:
|
||||||
docker build -t ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:$${VERSION} .
|
docker build \
|
||||||
|
-t ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:latest \
|
||||||
|
-t ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:$${VERSION} .
|
||||||
|
|
||||||
cmd-docker-push:
|
cmd-docker-push:
|
||||||
docker push ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}:$$VERSION
|
docker push -a ${REPO_OWNER_LOWER}/${REPO_NAME_SNAKE}
|
||||||
|
|
Loading…
Add table
Reference in a new issue