toluaina / pgsync

Postgres to Elasticsearch/OpenSearch sync
https://pgsync.com
MIT License
1.16k stars 181 forks source link

Error when building from source with dockerfile #346

Closed thienlehieu closed 2 years ago

thienlehieu commented 2 years ago

PGSync version: 2.3.2

Postgres version:

Elasticsearch version:

Redis version:

Python version:

Problem Description: Hi, i have made some changes with your source code and using docker to build service. The error happen when i add "ENV PYTHONPATH "${PYTHONPATH}:/code" , then "RUN python setup.py install" Below is the dockerfile causing to error, it works fine if i use "RUN pip install pgsync":

FROM python:3.7
ARG WORKDIR=/code
RUN mkdir $WORKDIR
WORKDIR $WORKDIR
ENV PYTHONPATH "${PYTHONPATH}:/code"
COPY . .
RUN python setup.py install
# RUN pip install pgsync
COPY ./docker/wait-for-it.sh wait-for-it.sh
COPY ./docker/runserver.sh runserver.sh
RUN chmod +x wait-for-it.sh
RUN chmod +x runserver.sh
CMD sh ./runserver.sh

Error Message (if any):

pgsync_1         | Traceback (most recent call last):
pgsync_1         |     __import__('pkg_resources').run_script('pgsync==2.3.2', 'bootstrap')
pgsync_1         |   File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 651, in run_script
pgsync_1         |     self.require(requires)[0].run_script(script_name, ns)
pgsync_1         |   File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1438, in run_script
pgsync_1         |     .format(**locals()),
pgsync_1         | pkg_resources.ResolutionError: Script 'scripts/bootstrap' not found in metadata at '/code/pgsync.egg-info'
pgsync_1         | Traceback (most recent call last):
pgsync_1         |   File "/usr/local/bin/pgsync", line 4, in <module>
pgsync_1         |     __import__('pkg_resources').run_script('pgsync==2.3.2', 'pgsync')
pgsync_1         |   File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 651, in run_script
pgsync_1         |     self.require(requires)[0].run_script(script_name, ns)
pgsync_1         |   File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1438, in run_script
pgsync_1         |     .format(**locals()),
pgsync_1         | pkg_resources.ResolutionError: Script 'scripts/pgsync' not found in metadata at '/code/pgsync.egg-info'
pgsync_pgsync_1 exited with code 1