Amazon Linux 2023 dependencies issue

0

Hi community! While deploying new app to production with AWS Beanstalk AL2023 python 3.11 machine, old problem popped up with one particular python package which has non-python dependencies - weasyprint. Those include libraries like cairo and pango for image processing. Current Al2023 machine on Beanstalk installs those dependencies but python server fails to render images inside pdf and no visible errors can be found. So in order to test it I've taken "amazonlinux:2023" Docker image and it turned out installing the same packages lead to different results - all images in rendered pdf appeared to be in place. I know it's not 100% the same OS image, but still. Any hints what can be different between these two cases?

predeploy script from Beanstalk app

#!/bin/bash
sudo dnf update -y
sudo dnf -y install gcc tar pkgconf-pkg-config make cmake pango-devel pango cairo-devel cairo
sudo dnf clean all

Dockerfile from local test

FROM amazonlinux:2023

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV APP_HOME /app
ENV PYTHONPATH=${PYTHONPATH}:${PWD} 
ENV PYTHONFAULTHANDLER 1
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

# Install pipenv and compilation dependencies
# install[] dependencies
RUN dnf update
RUN dnf -y install python3.11 python3-pip gcc tar pkgconf-pkg-config make cmake pango-devel pango cairo-devel cairo
RUN dnf clean all
RUN pip3 install pipenv

# Install python dependencies in /.venv
COPY Pipfile .
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy --skip-lock

ENV PATH="/.venv/bin:$PATH"

# set work directory
RUN mkdir /app
# RUN /usr/sbin/useradd addgroup --system app && adduser --system --group app
WORKDIR $APP_HOME

COPY . ./

EXPOSE 8000

CMD ["gunicorn", "core.wsgi:application", "--bind", ":8000"]
profile picture
asked 4 months ago564 views
1 Answer
-1

Specify the exact Python version (Python 3.11) to be used. Set the same environment variables (PYTHONDONTWRITEBYTECODE, PYTHONUNBUFFERED, etc.). Use Pipenv and a virtual environment for managing Python dependencies. Ensure the work directory and file paths are consistent with the Docker setup.

Amir
answered 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions