Skip to content

Commit c62a43b

Browse files
authored
Use explicit python version for Docker and Circle (#104)
We cache a virtualenv on CircleCI, and when there are new patch releases of Python and Circle upgrades, we have problems, because the cache's symlink for Python starts pointing to nowhere. This will help prevent that problem. I figured it makes sense to lock down a specific version of Python in the Dockerfile while we’re at it.
1 parent 5f79cfb commit c62a43b

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

.circleci/config.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
version: 2.1
2+
3+
parameters:
4+
python-version:
5+
type: string
6+
default: "3.7.13"
7+
28
jobs:
39
build:
410
working_directory: ~/web-monitoring-diff
511
docker:
6-
- image: cimg/python:3.7
12+
- image: cimg/python:<< pipeline.parameters.python-version >>
713
steps:
814
- checkout
915
- run:
@@ -15,11 +21,11 @@ jobs:
1521
1622
- restore_cache:
1723
keys:
18-
- cache-v2-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-experimental.txt" }}
19-
- cache-v2-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-
20-
- cache-v2-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-
21-
- cache-v2-{{ arch }}-{{ checksum "requirements.txt" }}-
22-
- cache-v2-{{ arch }}-
24+
- cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-experimental.txt" }}
25+
- cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-
26+
- cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-
27+
- cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-{{ checksum "requirements.txt" }}-
28+
- cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-
2329

2430
# Bundle install dependencies
2531
- run:
@@ -32,7 +38,7 @@ jobs:
3238
3339
# Store bundle cache
3440
- save_cache:
35-
key: cache-v2-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-experimental.txt" }}
41+
key: cache-v2-{{ arch }}-python<< pipeline.parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "requirements-server.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "requirements-experimental.txt" }}
3642
paths:
3743
- venv
3844

@@ -58,7 +64,8 @@ jobs:
5864
# cd docs && make html
5965

6066
build_docker:
61-
machine: true
67+
machine:
68+
image: ubuntu-2004:202111-02
6269
steps:
6370
- checkout
6471
- run: |
@@ -74,7 +81,8 @@ jobs:
7481
- docker-image
7582

7683
publish_docker:
77-
machine: true
84+
machine:
85+
image: ubuntu-2004:202111-02
7886
steps:
7987
- attach_workspace:
8088
at: /tmp/workspace

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# We separate them out so that the final `release` image can layer on top of
77
# this one without needing compiler-related packages.
88
##
9-
FROM python:3.7-slim as base
9+
FROM python:3.7.13-slim as base
1010
LABEL maintainer="enviroDGI@gmail.com"
1111

1212
RUN apt-get update && apt-get install -y --no-install-recommends \

0 commit comments

Comments
 (0)