Skip to content

Commit ae51824

Browse files
author
Irving Popovetsky
committed
the most minimal security and build updates
Signed-off-by: Irving Popovetsky <irving@honeycomb.io>
1 parent 75ee8b9 commit ae51824

2 files changed

Lines changed: 50 additions & 16 deletions

File tree

docker-build.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh -ex
2+
3+
# Build and push ARM64 image using buildx with provenance disabled
4+
docker buildx build \
5+
--platform linux/arm64 \
6+
--file docker/Dockerfile \
7+
--tag 633607774026.dkr.ecr.us-east-2.amazonaws.com/pybot:arm64 \
8+
--provenance=false \
9+
--push .
10+
11+
# Build and push AMD64 image using buildx with provenance disabled
12+
docker buildx build \
13+
--platform linux/amd64 \
14+
--file docker/Dockerfile \
15+
--tag 633607774026.dkr.ecr.us-east-2.amazonaws.com/pybot:amd64 \
16+
--provenance=false \
17+
--push .
18+
19+
# Remove existing manifest list if it exists
20+
docker manifest rm 633607774026.dkr.ecr.us-east-2.amazonaws.com/pybot || true
21+
22+
# Create manifest list
23+
docker manifest create \
24+
633607774026.dkr.ecr.us-east-2.amazonaws.com/pybot \
25+
633607774026.dkr.ecr.us-east-2.amazonaws.com/pybot:amd64 \
26+
633607774026.dkr.ecr.us-east-2.amazonaws.com/pybot:arm64
27+
28+
docker manifest inspect 633607774026.dkr.ecr.us-east-2.amazonaws.com/pybot
29+
30+
# Push the manifest
31+
docker manifest push 633607774026.dkr.ecr.us-east-2.amazonaws.com/pybot

docker/Dockerfile

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
FROM python:3.7-alpine AS base
22

3-
FROM base as builder
3+
FROM base AS builder
44

5-
ENV PIP_DISABLE_PIP_VERSION_CHECK on
6-
ENV PYTHONDONTWRITEBYTECODE 1
7-
ENV PYTHONUNBUFFERED 1
5+
ENV PIP_DISABLE_PIP_VERSION_CHECK=on
6+
ENV PYTHONUNBUFFERED=1
87

9-
RUN apk update && \
10-
apk add --no-cache build-base musl-dev python3-dev libffi-dev openssl-dev
8+
RUN apk update
9+
RUN apk upgrade
10+
RUN apk add --no-cache build-base musl-dev python3-dev libffi-dev openssl-dev
1111

1212
RUN python -m venv /opt/venv
1313
# Make sure we use the virtualenv:
1414
ENV PATH="/opt/venv/bin:$PATH"
1515

1616
COPY poetry.lock pyproject.toml ./
1717

18-
RUN pip install poetry && \
19-
poetry config virtualenvs.create false && \
20-
poetry install --no-dev --no-interaction
18+
RUN pip install poetry
19+
RUN poetry config virtualenvs.create false
20+
RUN poetry install --only=main --compile --no-interaction --no-cache
2121

2222
# The `built-image` stage is the base for all remaining images
2323
# Pulls all of the built dependencies from the builder stage
24-
FROM base as built-image
25-
ENV PIP_DISABLE_PIP_VERSION_CHECK on
26-
ENV PYTHONDONTWRITEBYTECODE 1
27-
ENV PYTHONUNBUFFERED 1
24+
FROM base AS built-image
25+
ENV PIP_DISABLE_PIP_VERSION_CHECK=on
26+
ENV PYTHONUNBUFFERED=1
27+
28+
RUN apk update
29+
RUN apk upgrade
30+
RUN rm -rf /var/cache/apk/*
2831

2932
# copy installed deps from builder image
3033
COPY --from=builder /opt/venv /opt/venv
@@ -34,12 +37,12 @@ ENV PATH="/opt/venv/bin:$PATH"
3437

3538
# The `app` stage is used as the base for images that don't
3639
# need the development dependencies
37-
FROM built-image as app
40+
FROM built-image AS app
3841

3942
COPY . /src
4043
WORKDIR /src
4144

42-
# The `Prod` stage creates an image that will run the application using a
45+
# The `prod` stage creates an image that will run the application using a
4346
# production webserver and the `environments/production.py` configuration
44-
FROM app As Prod
47+
FROM app AS prod
4548
ENTRYPOINT ["python3", "-m", "pybot"]

0 commit comments

Comments
 (0)