AWS ElasticBeanstalk amazon linux pg_config error with psycopg2 - postgresql

I am testing AWS for launching web service.
I stuck with pg_config. Error log is
/app/requirements.txt (line 1))
Using cached psycopg2-2.6.2.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
There are many solutions in stackoverflow, but it doesn't work for me.
packages:
yum:
python-devel: []
postgresql95-devel: []
libjpeg-devel: '6b'
container_commands:
01_migrate:
command: "python manage.py migrate"
02_collectstatic:
command: "python manage.py collectstatic --noinput"
03_createsu:
command: "python manage.py createsu"
leader_only: true
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "onreview.settings"
PYTHONPATH: "$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: "onreview/wsgi.py"
This is my .ebextensions/python.config files contents. And I'm uploading through zipping my source code.
I changed postgresql95-devel to postgresql-devel, 93, 94, all of it. And I use 9.5 version db right now.
I think --pg-config's path is problem. but I can't change it.
Is there any solution??
p.s I do not want to setup inside the EC2 instance through SSH or something.

You have a syntax error in your original post, packages: should not be indented. I don't know why you have python-devel when python is included in the install, so I can't say that it isn't interfering. Likewise with the line setting the python path.
packages:
yum:
python-devel: []
postgresql95-devel: []
libjpeg-devel: '6b'
container_commands:
01_migrate:
command: "python manage.py migrate"
02_collectstatic:
command: "python manage.py collectstatic --noinput"
03_createsu:
command: "python manage.py createsu"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: "onreview.settings"
PYTHONPATH: "$PYTHONPATH"
aws:elasticbeanstalk:container:python:
WSGIPath: "onreview/wsgi.py"

Related

running elixir on buildkite with docker-compose fails with dependencies

i have the following dockerfile for an elixir+phoenix app
FROM elixir:latest as build_base
RUN apt-get -y update
RUN apt-get -y install inotify-tools curl
ARG TARGETARCH
RUN if [ ${TARGETARCH} = arm64 ]; then \
curl -L -o /tmp/dart-sass.tar.gz https://github.com/sass/dart-sass/releases/download/1.54.5/dart-sass-1.54.5-linux-${TARGETARCH}.tar.gz \
;else \
curl -L -o /tmp/dart-sass.tar.gz https://github.com/sass/dart-sass/releases/download/1.54.5/dart-sass-1.54.5-linux-x64.tar.gz \
;fi
RUN tar -xvf /tmp/dart-sass.tar.gz -C /tmp
RUN mv /tmp/dart-sass/sass /usr/local/bin/sass
RUN mkdir -p /app
WORKDIR /app
COPY mix.* ./
RUN mix local.hex --force
RUN mix archive.install hex phx_new --force
RUN mix local.rebar --force
RUN mix deps.clean --all
RUN mix deps.get
RUN mix --version
RUN mix deps.compile
COPY assets assets
COPY vendor vendor
COPY lib lib
COPY config config
COPY priv priv
COPY test test
RUN mix compile
the docker-compose file looks like the following
services:
web:
build:
context: .
dockerfile: Dockerfile
target: build_base
volumes:
- ./:/app
ports:
- "80:80"
command: mix phx.server
I'm trying to run docker-compose as part of the build step in buildkite, this is an extract of the step in buildkite
- label: "run web"
key: "web"
commands:
- mix phx.server
plugins:
- docker-compose#v4.9.0:
run: web
config: docker-compose.yml
however when running web i see everything happens properly including the package installation, however when running the application i see the following error
web_1 | Unchecked dependencies for environment dev:
web_1 | * telemetry_metrics (Hex package)
web_1 | the dependency is not available, run "mix deps.get"
and the list goes on and on, this works fine on my local machine, its only when running on buildkite. does anyone have any idea on how to fix this ?

Ansible. Error during use docker-compose module. No module named 'docker'

I have a problem with run my playbook.yml with docker-compose module
---
- name: Deploying asistant application services
hosts: 1.1.1.1
vars:
dest_path: /my/path
become: yes
tasks:
- name: coping file docker-compose.yml
copy:
src: ./app/docker-compose.yml
dest: "{{ dest_path }}"
loop:
- docker-compose.yml
- name: run docker applications
docker_compose:
project_src: "{{ dest_path }}"
Python version
~$ python --version
Python 3.9.4
Ansible version
~$ ansible --version
ansible [core 2.11.6]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/rafal/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/rafal/.local/lib/python3.9/site-packages/ansible
ansible collection location = /home/rafal/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.4 (default, Nov 19 2021, 16:27:14) [GCC 8.3.0]
jinja version = 3.0.3
libyaml = True
I have also installed
~$ pip3 list | grep docker
docker 5.0.3
docker-compose 1.29.2
docker-py 1.10.6
docker-pycreds 0.4.0
dockerpty 0.4.1
Python3 in my system was installed in /user/local/bin
Python2.7.16 in my system was installed in /user/bin
Run command.
python3 $(which ansible-playbook) playbook.yml -u user -K -vvv
And result after run
"msg": "Failed to import the required Python library (Docker SDK for Python: docker above 5.0.0 (Python >= 3.6) or docker before 5.0.0 (Python 2.7) or docker-py (Python 2.6)) on ASSISTANT-DEV's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` (Python >= 3.6) or `pip install docker==4.4.4` (Python 2.7) or `pip install docker-py` (Python 2.6). The error was: No module named 'docker'"
}
Actually I don't have any idea what installed yet, or what, where a must set

Error to install psycopg2 install in aws(ubuntu) , how to solve?

Collecting psycopg2 Using cached psycopg2-2.8.5.tar.gz (380 kB)
ERROR: Command errored out with exit status 1: command: /home/ubuntu/egrdb/env/bin/python -c 'import sys, setuptools, tokenize; sys.argv0 = '"'"'/tmp/pip-install-gn70jweq/psycopg2/setup.py'"'"'; file='"'"'/tmp/pip-install-gn70jweq/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-4tr67ll8 cwd: /tmp/pip-install-gn70jweq/psycopg2/ Complete output (7 lines): running egg_info creating /tmp/pip-pip-egg-info-4tr67ll8/psycopg2.egg-info writing /tmp/pip-pip-egg-info-4tr67ll8/psycopg2.egg-info/PKG-INFO writing dependency_links to /tmp/pip-pip-egg-info-4tr67ll8/psycopg2.egg-info/dependency_links.txt writing top-level names to /tmp/pip-pip-egg-info-4tr67ll8/psycopg2.egg-info/top_level.txt writing manifest file '/tmp/pip-pip-egg-info-4tr67ll8/psycopg2.egg-info/SOURCES.txt' Error: b'You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.\n'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
If you want to install the source version psycopg2-2.8.5.tar.gz then you will need to do as #Chris says. The simpler way though is to do:
pip install psycopg2-binary
Then you get a pre-compiled version and you don't need the -dev packages.

CommandError: /code/manage.py already exists, overlaying a project or app into an existing directory won't replace conflicting files

I'm trying to run linux docker on windows and getting this error.
build was fine.
'''
$ docker-compose build
Building web
Step 1/11 : FROM python:3
---> 42d620af35be
Step 2/11 : ENV PYTHONUNBUFFERED 1
---> Using cache
---> b43065732d6e
Step 3/11 : RUN apt-get update -y
---> Using cache
---> 6f65e0da9e14
Step 4/11 : RUN apt-get install -y unixodbc unixodbc-dev
---> Using cache
---> 2a9d7445a991
Step 5/11 : RUN easy_install pip
---> Using cache
---> 5994e6452e09
Step 6/11 : RUN mkdir /code
---> Using cache
---> d0eaa870fb98
Step 7/11 : WORKDIR /code
---> Using cache
---> af78d4b35f26
Step 8/11 : RUN pip uninstall django
---> Using cache
---> 92f983bfef88
Step 9/11 : COPY requirements.txt /code/
---> Using cache
---> 3c0031987286
Step 10/11 : RUN pip install -r requirements.txt
---> Using cache
---> 3915127d3d58
Step 11/11 : COPY . /code/
---> Using cache
---> de872685c733
Successfully built de872685c733
Successfully tagged djangoproject_web:latest
'''
but when i run compose up.. i see below error.
'''
$ docker-compose up
Creating djangoproject_web_1 ... done
Attaching to djangoproject_web_1
web_1 | Watching for file changes with StatReloader
web_1 | Performing system checks...
web_1 |
web_1 | System check identified no issues (0 silenced).
web_1 |
web_1 | You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
web_1 | Run 'python manage.py migrate' to apply them.
web_1 | July 23, 2019 - 03:21:21
web_1 | Django version 2.2.3, using settings 'composeexample.settings'
web_1 | Starting development server at http://case.xxxxxx.com:8000/
web_1 | Quit the server with CONTROL-C.
web_1 | Error: [Errno -2] Name or service not known
djangoproject_web_1 exited with code 1
'''
and if i try this
'''
docker-compose run web django-admin startproject composeexample .
'''
it says
'''
CommandError: /code/manage.py already exists, overlaying a project or app into an existing directory won't replace conflicting files
'''
my Dockerfile is
'''
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN apt-get update -y
RUN apt-get install -y unixodbc unixodbc-dev
RUN easy_install pip
RUN mkdir /code
WORKDIR /code
RUN pip uninstall django
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
'''
my docker-compose.yml is
'''
version: '3'
services:
web:
build: .
command: python manage.py runserver case.xxxxxx.com:8000
volumes:
- .:/code
ports:
- "8000:8000"
'''
How can i fix the problem with composeexample? it is not even created (cause i can't see it in the folder).. your advice please.
You are probably using the docker client of Ubuntu Windows Subsystem. This gives issues with Volume feature of docker.
Run the docker run command on windows powershell and this issue will not come.
This error occurs if you try to create another project in a single virtual environment. To remove error and create next project delete "manage.py file" which is the file automatically created while starting project.
If you still get error delete the virtual environment and delete manage.py
You have 2 conflicting/overwriting statements:
In your Dockerfile:
COPY . /code/
in your docker-compose.yml:
volumes:
- .:/code
I suggest you remove the COPY statement from the Dockerfile and re-run your containers using docker-compose.
Also, you can remove the RUN command here:
RUN mkdir /code
WORKDIR /code
It is not an error, but WORKDIR already creates the folder if it doesn't exist anyway.
The problem is, you are trying to create a project that is already created by re-running the command
docker-compose run web django-admin startproject composeexample .
Just run
docker-compose run web

rpmbuild on CentOS: no such file or directory

I have created a simple RPM on Fedora27 and it worked fine. It just copied files from tar.gz to /usr/bin/.
When I tried to install this RPM on CentOS I got:
# rpm -i RPMS/x86_64/my_rpm-0.0-5.x86_64.rpm --force
error: Failed dependencies:
libc.so.6(GLIBC_2.26)(64bit) is needed by my_rpm-0.0-5.x86_64
So I assumed I will need to create the RPM on CentOS.
But when I do so I get a weird: 'No such file or directory' that I don't get on Fedora27. Here is a sketch of my spec file:
%define _topdir %(pwd)
%define name my_rpm
%define release 5
%define version 0.0
%define buildroot %{_topdir}/%{name}-%{release}-root
BuildRoot: %{buildroot}
Summary: my_rpm
License: -
Name: %{name}
Release: %{release}
Version: %{version}
Source: %{name}-%{version}-%{release}.tar.gz
Prefix: /usr
Group: Tools
%description
This is my_rpm spec file
%prep
%setup -q -n %(arch)/%{name}-%{version}
%install
install -D my_app -t %{buildroot}/usr/bin/my_rpm/
%files
/usr/bin/my_rpm/*
When I try to build the RPM for it I get:
# rpmbuild -v -bb --clean SPECS/bpf.spec
+ install -D app -t /root/rpmbuild/BUILDROOT/my_rpm-0.0-5.x86_64/usr/bin/my_rpm/
install: failed to access '/root/rpmbuild/BUILDROOT/my_rpm-0.0-5.x86_64/usr/bin/my_rpm/': No such file or directory
The same SPEC exactly runs smoothly on Fedora27.
What should I change in it my spec file so that it would work both on Fedora27 and CentOS7? or maybe I can fix my initial problem with Glibc?
EDIT 1
I added the "mkdir -p ..." command under install and the build was successful but it still gives me the same error, that I need Glibc 2.6.
What I don't understand is why during the build it says:
Requires: libc.so.6()(64bit) libc.so.6(GLIBC_2.14)(64bit) libc.so.6(GLIBC_2.2.5)(64bit) libc.so.6(GLIBC_2.26)(64bit) libc.so.6(GLIBC_2.3)(64bit) libc.so.6(GLIBC_2.3.4)(64bit) libc.so.6(GLIBC_2.7)(64bit) libc.so.6(GLIBC_2.9)(64bit) libelf.so.1()(64bit) libelf.so.1(ELFUTILS_1.0)(64bit) rtld(GNU_HASH)
Edit 2(solution)
I got it to work. My executables are compiled C code. So I had to re-compile everything on CentOS and then build the rpm. Now it works on both Fedora and CentOS.