I'm seeing the following error when running docker-compose up
on my Flask application:
server | Traceback (most recent call last):
server | File "/app/app.py", line 3, in <module>
server | import boto3
server | File "/usr/local/lib/python3.9/site-packages/boto3/__init__.py", line 16, in <module>
server | from boto3.session import Session
server | File "/usr/local/lib/python3.9/site-packages/boto3/session.py", line 17, in <module>
server | import botocore.session
server | File "/usr/local/lib/python3.9/site-packages/botocore/session.py", line 29, in <module>
server | import botocore.configloader
server | ValueError: source code string cannot contain null bytes
server exited with code 1
Inside my Flask app.py
I have the following:
import flask
import pandas as pd
import boto3
client = boto3.client('s3')
path = 's3://my-bucket/my-file.csv'
df = pd.read_csv(path)
...
When doing flask run
on its own, however, everything works fine. My docker-compose.yml
looks like this:
version: "3.9"
services:
server:
container_name: server
build: ./server
ports:
- "80:5000"
volumes:
- ./server:/app
environment:
FLASK_ENV: development
env_file:
- ./.env
web:
build: ./app
ports:
- "3000:3000"
volumes:
- ./app:/user/src/app
depends_on:
- server
and the Dockerfile
:
FROM python
WORKDIR /app
ENV FLASK_APP=app.py
ENV FLASK_ENV=development
COPY ./requirements.txt .
RUN pip3 install -r requirements.txt
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ENV AWS_REGION='eu-west-2'
COPY . .
CMD ["python3", "app.py"]
Is there a way to fix this?