Skip to content

Commit

Permalink
Merge b5d2e77 into 5a5bf2a
Browse files Browse the repository at this point in the history
  • Loading branch information
Nischay-Pro committed Sep 12, 2023
2 parents 5a5bf2a + b5d2e77 commit 0137474
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ upgrade-deps:
rm requirements/app.txt
rm requirements/test.txt

ifneq ($(docker), yes)
# Run tests only if not in docker
make test
endif

# ---- Data ----

Expand Down
17 changes: 17 additions & 0 deletions ci/Dockerfile.update
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG PYTHON_VERSION

FROM python:${PYTHON_VERSION}-slim-bookworm as update

# Install dependencies

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*

# Copy the source code

COPY . /app
WORKDIR /app

CMD ["python", "--version"]
53 changes: 53 additions & 0 deletions ci/update-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

######################################################################
# This script sets up the docker environment for updating packages
######################################################################

set -e
set -x

# Check if docker is installed
if ! [ -x "$(command -v docker)" ]; then
echo "Docker is not installed. Please install docker and try again."
exit 1
fi

# Check if we can run docker without sudo
if ! docker ps > /dev/null 2>&1; then
echo "Docker is not running without sudo. Please add your user to the docker group and try again."
exit 1
fi

SOURCE_DIR=$(pwd)/../

TEMP_DIR=$(mktemp -d)

# Copy the current directory to the temp directory
cp -r ../ $TEMP_DIR

cd $TEMP_DIR

PYTHON_VERSIONS=(3.8 3.9 3.10 3.11)

for PYTHON_VERSION in "${PYTHON_VERSIONS[@]}"
do
# Remove container if it exists
docker rm --force flexmeasures-update-packages-$PYTHON_VERSION || true
# Build the docker image
docker build --build-arg=PYTHON_VERSION=$PYTHON_VERSION -t flexmeasures-update-packages:$PYTHON_VERSION . -f ci/Dockerfile.update
# Build flexmeasures
docker run --name flexmeasures-update-packages-$PYTHON_VERSION -it flexmeasures-update-packages:$PYTHON_VERSION make upgrade-deps docker=yes
# Copy the requirements to the source directory
docker cp flexmeasures-update-packages-$PYTHON_VERSION:/app/requirements/$PYTHON_VERSION $SOURCE_DIR/requirements/
# Remove the container
docker rm flexmeasures-update-packages-$PYTHON_VERSION
# Remove the image
docker rmi flexmeasures-update-packages:$PYTHON_VERSION
done

# Clean up docker builder cache
# docker builder prune --all -f

# Remove the temp directory
rm -rf $TEMP_DIR

0 comments on commit 0137474

Please sign in to comment.