-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIVIS-9315] Fix apt-get and update AWS CLI (#97)
This fixes `apt-get` by updating the base image. Also: * Updates the AWS CLI to v2. * Makes `generate-requirements-full.sh` run in a docker container to ensure the environment matches. * Updates the code build config to use a FIPS URL (see, e.g., civisanalytics/datascience-r#52) and to run builds for branches. * Updates the major version to 8 since the AWS CLI major version changed. * Addresses https://github.com/civisanalytics/datascience-python/security/dependabot/10
- Loading branch information
Showing
10 changed files
with
89 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
FROM python:3.12.4-slim AS production | ||
ARG PLATFORM=linux/x86_64 | ||
ARG BASE_IMAGE=python:3.12.5-slim | ||
|
||
LABEL maintainer = [email protected] | ||
# This is the primary build target used for the production image | ||
FROM --platform=$PLATFORM $BASE_IMAGE AS production | ||
|
||
# Disable pip warnings https://stackoverflow.com/a/72551258 | ||
ENV PIP_ROOT_USER_ACTION=ignore | ||
|
||
LABEL [email protected] | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive apt-get update -y --no-install-recommends && \ | ||
apt-get install -y --no-install-recommends locales && \ | ||
|
@@ -19,7 +26,9 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update -y --no-install-recommends && | |
libxrender1 \ | ||
wget \ | ||
ca-certificates \ | ||
curl && \ | ||
curl \ | ||
mandoc \ | ||
unzip && \ | ||
apt-get clean -y && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
|
@@ -34,14 +43,28 @@ RUN pip install --progress-bar off --no-cache-dir -r requirements-full.txt && \ | |
# https://github.com/joblib/joblib/blob/0.11/joblib/parallel.py#L328L342 | ||
ENV JOBLIB_TEMP_FOLDER=/tmp | ||
|
||
ENV VERSION=7.3.0 \ | ||
VERSION_MAJOR=7 \ | ||
VERSION_MINOR=3 \ | ||
ENV VERSION=8.0.0 \ | ||
VERSION_MAJOR=8 \ | ||
VERSION_MINOR=0 \ | ||
VERSION_MICRO=0 | ||
|
||
FROM production AS test | ||
# Install the AWSCLI for moving match targets in the QC workflow. | ||
# See https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#cliv2-linux-install | ||
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ | ||
unzip awscliv2.zip && \ | ||
./aws/install && \ | ||
rm -rf aws awscliv2.zip | ||
|
||
# This build target is for testing in Circle CI. | ||
FROM --platform=$PLATFORM production AS test | ||
COPY .circleci/test_image.py . | ||
COPY CHANGELOG.md . | ||
|
||
# Defaults to production as the final stage | ||
# This build target is for updating dependencies. | ||
# See generate-requirements.full.sh. | ||
FROM --platform=$PLATFORM $BASE_IMAGE AS pip-tools | ||
RUN pip install -U --no-cache-dir pip pip-tools --progress-bar off | ||
CMD ["/bin/bash"] | ||
|
||
# Default to the production build target. | ||
FROM production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: 0.2 | ||
phases: | ||
build: | ||
commands: | ||
- echo Logging in to Amazon ECR... | ||
- aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${FIPS_REPOSITORY_URI} | ||
- export COMMIT_HASH_SHORT="$(echo $COMMIT_HASH | cut -c 1-7)" | ||
- echo Building the Docker image... | ||
- echo $FIPS_REPOSITORY_URI | ||
- echo $COMMIT_HASH_SHORT | ||
- echo $BRANCH_NAME | ||
- docker build --tag ${FIPS_REPOSITORY_URI}:${COMMIT_HASH_SHORT} --tag ${FIPS_REPOSITORY_URI}:${BRANCH_NAME} . | ||
# This config tests the codebuild login and the build but does not push dev images. | ||
# The following lines can be temporarily uncommented to test a dev image. | ||
# - docker image push --all-tags ${FIPS_REPOSITORY_URI} | ||
post_build: | ||
commands: | ||
- echo Build completed! | ||
- printf '{"tag":"%s"}' $COMMIT_HASH_SHORT > build.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
services: | ||
pip-tools: | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile | ||
target: pip-tools | ||
volumes: | ||
- .:/app | ||
stdin_open: true | ||
tty: true | ||
working_dir: /app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/bash | ||
python --version | ||
pip install --upgrade pip-tools | ||
pip-compile --output-file=requirements-full.txt --pip-args='--prefer-binary' --strip-extras --upgrade requirements-core.txt | ||
# Run this script to update requirements-core.txt. | ||
# It uses Docker to ensure that the environment matches what will be used in the production image. | ||
set -e | ||
docker compose run --rm pip-tools /bin/sh -c "pip install --upgrade pip-tools && pip-compile --output-file=requirements-full.txt --pip-args='--prefer-binary' --strip-extras --upgrade requirements-core.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
awscli==1.33.9 | ||
boto3==1.34.127 | ||
civis==2.3.0 | ||
numpy==2.0.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters