-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
54 lines (39 loc) · 1.48 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Terraform version passed in from Drone
ARG TERRAFORM_VERSION=${TERRAFORM_VERSION}
# Will COPY terrafrom exe FROM this source image
FROM hashicorp/terraform:${TERRAFORM_VERSION} as source_image
# Base our Docker image on the latest Alpine Linux image
FROM alpine
# Add the lastest Python3 & Pip
RUN apk add --update --upgrade --no-cache --virtual .run-deps \
python3 \
py3-pip \
git \
openssh
RUN rm -rf /var/cache/apk /root/.cache
# Get the latest terraform binary
COPY --from=source_image /bin/terraform /usr/local/bin
WORKDIR /app
# Let Python know where to find the aws_terraform_test_runner module
ENV PYTHONPATH /app/aws_terraform_test_runner
# Python is now more fussy about upgrading the system environment - but we want to, we do not want to use a virtual env
ENV PIP_BREAK_SYSTEM_PACKAGES=1
# Install pip modules
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --upgrade setuptools
RUN pip install --no-cache-dir --quiet -r requirements.txt
RUN pip install --upgrade build
COPY . .
# Build the aws_terraform_test_runner module
RUN python -m build
# Check it's all good
RUN pylint **/*.py
RUN coverage run -m unittest tests/*_test.py
RUN coverage report
# Install the aws_terraform_test_runner module
RUN python -m pip install .
# Turn off the override - in case anyone else pip-installs further
ENV PIP_BREAK_SYSTEM_PACKAGES=0
# When this Docker Image is called, run this command to unit-test the python tests
ENTRYPOINT python -m unittest tests/*_test.py