"apt-get -y install libpq-dev gcc" over https? - https

In my dockerfile i'm trying to install binaries for Postgres, the thing is that the command:
RUN apt-get update \
&& apt-get -y install libpq-dev gcc
is trying to reach http://deb.debian.org/ over port 80.
Is there any way i can force this command to reference https://deb.debian.org/ over 443 instead of unencrypted http 80?

Related

sqlalchemy connection issue while running docker image on local window machine

docker image builds successfully. But when actually I run docker image using docker run command to check if my application works fine. I got the below issue.
Please need guidance over this issue. Thanks a lot
issue:
sqlalchemy.exc.DBAPIError: (pyodbc.Error) ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")
(Background on this error at: http://sqlalche.me/e/dbapi)
connection string:
def connectiondb():
params = urllib.parse.quote_plus(
"DRIVER={SQL Server};SERVER=servername;DATABASE=dbname;UID=username;PWD=password")
engine = sqlalchemy.create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)
metadata = MetaData(engine)
con = engine.connect()
dockerfile:
FROM python:latest
Bundle app source
COPY . /app
WORKDIR /app
Update
RUN pip install --upgrade pip
RUN apt-get update &&
apt-get install -y apt-transport-https &&
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - &&
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list &&
apt-get update &&
ACCEPT_EULA=Y apt-get install msodbcsql17 unixodbc-dev -y
RUN apt-get install libssl-dev
RUN pip install pyodbc==4.0.28
RUN pip install numpy==1.18.1
RUN pip install scikit-multiflow==0.4.1
RUN pip install Cython
RUN pip install scikit-learn==0.21.3
RUN pip install -r requirements.txt
EXPOSE 5000
CMD python ./app.py
return con, metadata,engine

Google Cloud Build and GLIBCXX_3.4.21 not found(for TexturePacker)

I'm trying to use Google Cloud Build to build my project which requires TexturePacker.
I managed to install TexturePacker but once script execute its CLI I get this error:
/usr/bin/../lib/texturepacker/TexturePacker_: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/bin/../lib/texturepacker/TexturePacker_)
Tried to install necessary lib but still no success (like below):
FROM gcr.io/cloud-builders/yarn
RUN apt-get update && apt-get install -y libgl1-mesa-glx
RUN apt-get install -y libstdc++6
RUN wget https://www.codeandweb.com/download/texturepacker/5.2.0/TexturePacker-5.2.0-ubuntu64.deb && dpkg -i TexturePacker-5.2.0-ubuntu64.deb
Does anyone has an idea on how to fix it?
I was managed to solve it using this Dockerfile:
FROM node:latest
RUN apt-get update
# Install updates and dependencies
RUN apt-get install --no-install-recommends -y -q curl python build-essential git ca-certificates libkrb5-dev imagemagick && \
apt-get clean && rm /var/lib/apt/lists/*_*
#TexturePacker and dependencies
RUN apt-get install -y libgl1-mesa-glx
RUN apt-get install -y libstdc++6
RUN wget https://www.codeandweb.com/download/texturepacker/5.2.0/TexturePacker-5.2.0-ubuntu64.deb && dpkg -i TexturePacker-5.2.0-ubuntu64.deb

`docker build` fails trying to install ubuntu packages

Trying to build a simple ubuntu apache web server docker image, I get an error while the docker build command tries installing packages. I am using the Ubuntu base image in Docker to do this. Below is the code in my Dockerfile;
FROM ubuntu
RUN apt-get update
RUN apt-get install apache2
RUN apt-get install apache2-utils
RUN apt-get clean
EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]
My Host OS is Mac OSX El Capitan, and the error I get when the build fails is;
The command '/bin/sh -c apt-get install apache2' returned a non-zero code: 1
and my docker build command is;
docker build -t="webserver" .
Any help please. Thanks in Advance.
You should use the '-y' apt-get flag when building an image.
apt-get will ask you permission to continue with apache installation, and since you can't interact with the apt-get while building the image, you must pass the '-y' flag that means 'yes' to apt-get prompt.
Try changing it to:
FROM ubuntu
RUN apt-get update
RUN apt-get install apache2 -y
RUN apt-get install apache2-utils -y
RUN apt-get clean
EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]
or even:
FROM ubuntu
RUN apt-get update && apt-get install apache2 apache2-utils -y
RUN apt-get clean
EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]

Answer '29' to apt-get install prompt for xorg

I'm using docker to put together a script and its get stuck when this package xorg asks the prompt for the country of origin for the keyboard, I'll attach the image.
I've tried piping in the command like this from other answers I've read
RUN echo "29" | apt-get install -y xorg
But it didn't seem to work. I'm not sure how I get this to auto answer 29. Any help is appreciated.
Reference to docker file
FROM ubuntu:16.04
MAINTAINER Joe Astrahan <email#hey.com>
VOLUME ["/var/www"]
#Install Apache & Basic Software
RUN apt-get update && \
apt-get install -y \
software-properties-common \
apache2 \
curl \
libcurl3 \
libcurl3-dev
#Install PHP 7.0 & mod apache
RUN apt-get install -y \
php7.0 \
php7.0-cli \
libapache2-mod-php7.0 \
php7.0-gd \
php7.0-json \
php7.0-ldap \
php7.0-mysqlnd \
php7.0-pgsql \
php7.0-curl \
php7.0-xml \
php7.0-xsl \
php7.0-zip \
php7.0-sqlite3 \
php7.0-ldap \
php7.0-json \
php7.0-mbstring \
php7.0-soap \
php7.0-intl \
php7.0-bcmath \
php7.0-gmp \
php7.0-mcrypt
#Install mysql, vim and openssl
RUN apt-get install -y \
mysql-client \
vim \
openssl
# Copy an initial PHP.ini file into the system with default settings
#COPY config/php.ini /etc/php5/apache2/php.ini
# Install php-5.5.30
#ADD config/install_php-5.5.30.sh /tmp/install_php-5.5.30.sh
#RUN /bin/bash /tmp/install_php-5.5.30.sh
# Set environment variables for Apache so we know its user and group names
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
# Configure Apache SSL and Standard Virtualhosts
COPY config/apache_default.conf /etc/apache2/sites-available/000-default.conf
COPY config/apache_default-ssl.conf /etc/apache2/sites-available/default-ssl.conf
COPY config/run /usr/local/bin/run
# Configure SSL Directories & Create Temporary SSL Keys
RUN mkdir /etc/apache2/ssl
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt -subj "/C=US/ST=Florida/L=Fort Lauderdale/O=Pool Service Software LLC/OU=IT Department/CN=dev.poolservice.software.local"
RUN chmod +x /usr/local/bin/run
RUN a2enmod rewrite
#Configure SSL On Apache2 & Headers Mod
RUN a2enmod ssl
RUN a2enmod headers
RUN service apache2 restart
RUN a2ensite default-ssl.conf
RUN service apache2 restart
#RUN apt-get install -y wkhtmltopdf
#Download and install composer and git
RUN apt-get install git -y
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
#Install Zip & Unzip
RUN apt-get install zip unzip -y
#Install NodeJS
#RUN curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
RUN apt-get install -y nodejs
RUN apt-get install -y npm
#Install UglifyCSS and JS
RUN npm install -g uglify-js
RUN npm install -g uglifycss
RUN npm install -g less
# Download and install wkhtmltopdf
RUN apt-get install -y build-essential
RUN echo "29" | apt-get install -y xorg
RUN apt-get install -y libssl-dev
RUN apt-get install -y libxrender-dev
RUN apt-get install -y wget
RUN apt-get install -y gdebi
RUN apt-get install -y libxrender1
RUN apt-get install -y xfonts-utils
RUN apt-get install -y xfonts-base
RUN apt-get install -y xfonts-75dpi
RUN apt-get install -y libfontenc1
RUN apt-get install -y x11-common
RUN apt-get install -y xfonts-encodings
RUN apt-get install -y libxfont1
RUN apt-get install -y fontconfig
RUN wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
RUN gdebi --n wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
RUN echo 'exec xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf "$#"' | tee /usr/local/bin/wkhtmltopdf.sh >/dev/null && sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh
EXPOSE 80
EXPOSE 443
CMD ["/usr/local/bin/run"]
There are quite a few issues I see with the Dockerfile provided.
Defining a volume inside the Dockerfile provides little to no value. It's much better to define this in your docker-compose.yml or as part of your run command. I've got a blog post going through the issues with this.
Splitting up the apt-get update from the later apt-get install commands can result in situations where the apt-get install will fail. There's a section in the best practices about this.
For your error message, I'd run apt-get in the noninteractive mode. You can also preconfigure debconf if you need a non-default value set during install.
Splitting each apt-get into a separate RUN command is creating lots of excessive layers, these should be merged where possible. This is also described in the best practices documentation.
Here's a sample of an install command that works for me taking the above into account:
FROM ubuntu:16.04
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
xorg \
libssl-dev \
libxrender-dev \
wget \
gdebi \
libxrender1 \
xfonts-utils \
xfonts-base \
xfonts-75dpi

Automate nginx installation via passenger

Every time we reinstall nginx using passenger, we have to provide to it a bunch of options to define the paths, modules and options we'd like to activate, which can be a bit of pain.
Does anybody know of a way to automate this using some kind of answer file?
Yes you can use a provisioning tool like Chef or Puppet but in some cases those can be overkill. I just have a Bash script with some variables at the top that get changed as necessary, I then just transfer the script to the target server and execute it.
The actual packages for nginx & passenger I keep in my own S3 bucket.
#!/bin/sh
# setup download location
DOWNLOAD_DIR=/tmp
NGINX="nginx-1.4.1"
NGINX_DIR=${DOWNLOAD_DIR}/${NGINX}
PASSENGER_VERSION="4.0.3"
S3HOST="your-s3-host"
# download nginx source
curl http://${S3HOST}.s3.amazonaws.com/software/${NGINX}.tar.gz -o $DOWNLOAD_DIR/${NGINX}.tar.gz
tar xzf $DOWNLOAD_DIR/${NGINX}.tar.gz --directory $DOWNLOAD_DIR
# download headers module
curl http://${S3HOST}.s3.amazonaws.com/software/headers-more-nginx-module-v0.16.zip -o $DOWNLOAD_DIR/headers-more-nginx-module-v0.16.zip
unzip $DOWNLOAD_DIR/headers-more-nginx-module-v0.16.zip -d $DOWNLOAD_DIR
# install passenger
apt-get install -y gcc g++ build-essential bison openssl libreadline6 lsof
apt-get install -y libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libpcre3-dev
apt-get install -y libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev libcurl4-openssl-dev
apt-get install -y default-jre python-software-properties imagemagick
apt-get install -y ruby1.9.3 ruby1.9.1-dev libruby1.9.1 rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 s3cmd
ln -nfs /var/lib/gems/1.9.1/bin/* /usr/bin/
gem install passenger -v ${PASSENGER_VERSION} --no-ri --no-rdoc
gem install bundler sass --no-ri --no-rdoc
# postgres client libraries
aptitude install software-properties-common -y
add-apt-repository -y ppa:pitti/postgresql
apt-get update
apt-get install -y postgresql-client-9.2 postgresql-server-dev-9.2
wget http://${S3HOST}.s3.amazonaws.com/software/passenger-enterprise-server-${PASSENGER_VERSION}.gem
gem install ./passenger-enterprise-server-${PASSENGER_VERSION}.gem --no-ri --no-rdoc
/var/lib/gems/1.9.1/gems/passenger-enterprise-server-${PASSENGER_VERSION}/bin/passenger-install-nginx-module \
--auto --prefix=/usr --nginx-source-dir=${NGINX_DIR} \
--extra-configure-flags="--conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --with-md5-asm --with-md5=/usr/include --with-sha1-asm --with-sha1=/usr/include --without-http_fastcgi_module --with-http_stub_status_module --with-http_ssl_module --add-module=${DOWNLOAD_DIR}/headers-more-nginx-module-v0.16"
# make proper folders
mkdir -p /etc/nginx/sites-enabled
mkdir -p /etc/nginx/conf.d
mkdir -p /var/tmp/nginx
mkdir -p /etc/nginx/ssl/rapidssl
mkdir -p /var/www/shared/log/old_logs
chown -R vino:vino /var/www
# cleanup the stupid files
rm /etc/nginx/*.default
# start from init script
update-rc.d nginx defaults
# cleanup
rm -rf $DOWNLOAD_DIR/nginx*
passenger-install-apache2-module supports non-interactive, automatic, headless installs or upgrades through command line options. You can use those options to automate answers. This is documented in the manual: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_non_interactive_automatic_headless_installs_or_upgrades
Alternatively, you can install Phusion Passenger as if it's a normal Nginx module, and use the normal Nginx installation automation scripts: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_installing_as_a_normal_nginx_module_without_using_the_installer
You could use a provisioning tool such as chef or puppet. It may be overkill to use it for this case on its own, but you could use it to prepare entire servers or workstations from the ground up.

Resources