Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions cloud-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Based on https://github.com/dhermes/python-multi
FROM gcr.io/google.com/cloudsdktool/cloud-sdk:latest

ENV DEBIAN_FRONTEND noninteractive

# Install dependencies.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
make \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
xz-utils \
tk-dev \
libxml2-dev \
libxmlsec1-dev \
git \
ca-certificates \
libffi-dev \
&& apt-get clean autoclean \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -f /var/cache/apt/archives/*.deb

# Install ``pyenv``.
RUN git clone https://github.com/pyenv/pyenv /root/.pyenv

# Install the desired versions of Python.
RUN for PYTHON_VERSION in 3.7.6 3.8.2; do \
set -ex \
&& /root/.pyenv/bin/pyenv install ${PYTHON_VERSION} \
&& /root/.pyenv/versions/${PYTHON_VERSION}/bin/python -m pip install --upgrade pip \
; done

# Add to PATH, in order of lowest precedence to highest.
ENV PATH /root/.pyenv/versions/3.7.6/bin:${PATH}
ENV PATH /root/.pyenv/versions/3.8.2/bin:${PATH}

CMD ["python3.8"]
26 changes: 26 additions & 0 deletions cloud-build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Cloud build image
=================

The Cloud Build trigger uses a custom image saved to the project's container registry. This image has executables for Python versions 3.7 and 3.8.

Use the files in this directory to create or update the custom image.


Build
-----

cd cloud-build
gcloud builds submit \
--project gae-secure-scaffold-python3 \
--config cloudbuild.yaml


The Docker image is based on https://github.com/dhermes/python-multi


Continuous integration
----------------------

The CI pipeline uses the Cloud Build GitHub app, and a Cloud Build trigger configured to fire when pull requests are made.

Cloud Build dashboard: https://console.cloud.google.com/cloud-build/dashboard?project=gae-secure-scaffold-python3
26 changes: 26 additions & 0 deletions cloud-build/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

steps:

- name: "gcr.io/cloud-builders/docker"
args:
- "build"
- "--tag"
- "gcr.io/$PROJECT_ID/multi-python-ci"
- "."

images:

- "gcr.io/$PROJECT_ID/multi-python-ci"
31 changes: 31 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

steps:

# See cloud-build/README.md for creating this image.
- name: 'gcr.io/$PROJECT_ID/multi-python-ci'
id: 'Create a virtualenv'
entrypoint: 'python'
args: ['-m', 'venv', '.venv']

- name: 'gcr.io/$PROJECT_ID/multi-python-ci'
id: 'Install testing tools'
entrypoint: '.venv/bin/pip'
args: ['install', 'nox']

# nox is configured with noxfile.py
- name: 'gcr.io/$PROJECT_ID/multi-python-ci'
id: 'Run tests'
entrypoint: '.venv/bin/nox'