-
Notifications
You must be signed in to change notification settings - Fork 0
Improving the Dockerfile #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: Setup Dev Python Environment | ||
| description: Set up Python 3.13 and install dev dependencies (requirements-dev.txt). | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Set up Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 | ||
| with: | ||
| python-version: '3.13' | ||
| cache: 'pip' | ||
|
|
||
| - name: Install dev dependencies | ||
| shell: bash | ||
| run: pip install -r requirements-dev.txt |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,9 @@ ARG SASL_SSL_ARTIFACTS=./sasl_ssl_artifacts | |
| # Trusted certs | ||
| COPY $TRUSTED_SSL_CERTS /opt/certs/ | ||
|
|
||
| # Production dependencies | ||
| COPY requirements.txt ${LAMBDA_TASK_ROOT}/requirements.txt | ||
|
|
||
| RUN \ | ||
| echo "######################################################" && \ | ||
| echo "### Import trusted certs before doing anything else ###" && \ | ||
|
|
@@ -36,33 +39,28 @@ RUN \ | |
| echo "### -> Basics ###" && \ | ||
| echo "### -> GCC (some makefiles require cmd which)###" && \ | ||
| echo "### -> dependencies for kerberos SASL_SSL ###" && \ | ||
| echo "### -> PostgreSQL dev headers (psycopg2) ###" && \ | ||
| echo "##############################################" && \ | ||
| dnf install -y \ | ||
| wget tar xz bzip2-devel zlib-devel \ | ||
| which make gcc gcc-c++ \ | ||
| libffi-devel cyrus-sasl-devel cyrus-sasl-gssapi openssl-devel krb5-workstation && \ | ||
| libffi-devel cyrus-sasl-devel cyrus-sasl-gssapi openssl-devel krb5-workstation postgresql-devel && \ | ||
| echo "#################" && \ | ||
| echo "### librdkafka ###" && \ | ||
| echo "#################" && \ | ||
| mkdir -p /tmp/env-install-workdir/librdkafka && \ | ||
| cd /tmp/env-install-workdir/librdkafka && \ | ||
| wget --ca-certificate=/etc/pki/tls/certs/ca-bundle.crt https://github.com/edenhill/librdkafka/archive/v2.4.0.tar.gz && \ | ||
| tar -xf v2.4.0.tar.gz && \ | ||
| cd /tmp/env-install-workdir/librdkafka/librdkafka-2.4.0 && \ | ||
| wget --ca-certificate=/etc/pki/tls/certs/ca-bundle.crt https://github.com/confluentinc/librdkafka/archive/v2.14.0.tar.gz && \ | ||
| tar -xf v2.14.0.tar.gz && \ | ||
| cd /tmp/env-install-workdir/librdkafka/librdkafka-2.14.0 && \ | ||
| ./configure && make && make install && \ | ||
| echo "###################" && \ | ||
| echo "### pip installs ###" && \ | ||
| echo "###################" && \ | ||
| pip install requests==2.31.0 urllib3==1.26.18 setuptools cryptography jsonschema PyJWT psycopg2-binary && \ | ||
| echo "######################" && \ | ||
| echo "### confluent-kafka ###" && \ | ||
| echo "######################" && \ | ||
| mkdir -p /tmp/env-install-workdir/confluent-kafka && \ | ||
| cd /tmp/env-install-workdir/confluent-kafka && \ | ||
| wget --ca-certificate=/etc/pki/tls/certs/ca-bundle.crt https://github.com/confluentinc/confluent-kafka-python/archive/v2.4.0.tar.gz && \ | ||
| tar -xf v2.4.0.tar.gz && \ | ||
| cd /tmp/env-install-workdir/confluent-kafka/confluent-kafka-python-2.4.0 && \ | ||
| CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/opt" python setup.py install && \ | ||
| # requirements.txt pins the version of confluent-kafka. | ||
| # --no-binary confluent-kafka forces source compilation against the system librdkafka | ||
| # built above, which includes Kerberos/GSSAPI support. The PyPI compiles without GSSAPI. | ||
| pip install -r ${LAMBDA_TASK_ROOT}/requirements.txt --no-binary confluent-kafka && \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. confluent-kafka - what is this about? It's also part of the requirements.txt file so why it's needed like this here?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, if I understand it correctly, the requirements.txt confluent-kafka pins its version. This --no-binary way of forcing source compilation against the system librdkafka, that is set above. That one includes the Kerberos support. The PyPI has an issue, that it compiles without GSSAPI (would break SASL_SSL authentication). So requirements holds the version and --no-binary says how pip builds the confluent-kafka dependency. I added a comment into the Dockerfile to be more clear about that step: 9fd16fc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I didn't know about any of this. Thanks! |
||
| echo "##############" && \ | ||
| echo "### cleanup ###" && \ | ||
| echo "##############" && \ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| -r requirements.txt | ||
| psycopg2-binary==2.9.12 | ||
| pytest==9.0.3 | ||
| pytest-cov==7.1.0 | ||
| pytest-mock==3.15.1 | ||
| pylint==4.0.5 | ||
| black==26.5.1 | ||
| mypy==2.1.0 | ||
| mypy-extensions==1.1.0 | ||
| moto[s3,secretsmanager,events]==5.2.1 | ||
| testcontainers==4.14.2 | ||
| docker==7.1.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,9 @@ | ||
| pytest==9.0.3 | ||
| pytest-cov==7.1.0 | ||
| pytest-mock==3.15.1 | ||
| pylint==4.0.5 | ||
| black==26.5.1 | ||
| mypy==2.1.0 | ||
| mypy-extensions==1.1.0 | ||
| urllib3==2.7.0 | ||
| cryptography==48.0.0 | ||
| jsonschema==4.26.0 | ||
| PyJWT==2.13.0 | ||
| requests==2.34.2 | ||
| boto3==1.43.14 | ||
| aiosql==15.0 | ||
| botocore==1.43.14 | ||
| aiosql==15.0 | ||
| confluent-kafka==2.14.0 | ||
| moto[s3,secretsmanager,events]==5.2.1 | ||
| testcontainers==4.14.2 | ||
| docker==7.1.0 | ||
| # psycopg2-binary==2.9.10 # Ideal for local development, but not for long-term production use | ||
| psycopg2==2.9.12 |
Uh oh!
There was an error while loading. Please reload this page.