I have used the following dockerfile to add MS SQL Server drivers to Sail.
FROM ubuntu:22.04
LABEL maintainer="Taylor Otwell"
ARG WWWGROUP
ARG NODE_VERSION=16
ARG POSTGRES_VERSION=14
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
&& mkdir -p ~/.gnupg \
&& chmod 600 ~/.gnupg \
&& echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
&& echo "keyserver hkp://keyserver.ubuntu.com:80" >> ~/.gnupg/dirmngr.conf \
&& gpg --recv-key 0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c \
&& gpg --export 0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c > /usr/share/keyrings/ppa_ondrej_php.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
&& apt-get update \
&& apt-get install -y php8.1-cli php8.1-dev \
php8.1-pgsql php8.1-sqlite3 php8.1-gd \
php8.1-curl \
php8.1-imap php8.1-mysql php8.1-mbstring \
php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap \
php8.1-intl php8.1-readline \
php8.1-ldap \
php8.1-msgpack php8.1-igbinary php8.1-redis php8.1-swoole \
php8.1-memcached php8.1-pcov php8.1-xdebug \
&& php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarn.gpg >/dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y yarn \
&& apt-get install -y mysql-client \
&& apt-get install -y postgresql-client-$POSTGRES_VERSION \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Add repository ODBC and Install the Microsoft ODBC driver for SQL Server
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install -y msodbcsql18 \
&& ACCEPT_EULA=Y apt-get install -y mssql-tools18 \
&& apt-get install -y unixodbc-dev
# Install the PHP drivers for Microsoft SQL Server \
RUN pecl config-set php_ini /etc/php/8.1/fpm/php.ini \
&& pecl install sqlsrv \
&& pecl install pdo_sqlsrv \
&& su \
&& printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.1/mods-available/sqlsrv.ini \
&& printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.1/mods-available/pdo_sqlsrv.ini \
&& exit \
&& phpenmod -v 8.1 sqlsrv pdo_sqlsrv
RUN apt-get install freetds-common freetds-bin unixodbc php8.1-sybase
RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/8.1/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container
EXPOSE 8000
ENTRYPOINT ["start-container"]
I then add the sqlsrv connection details to my .env.
DB_CONNECTION=sqlsrv
DB_HOST=localhost
DB_PORT=1433
DB_DATABASE=sqlsrv_project
DB_USERNAME=user
DB_PASSWORD=password
When I run sail artisan migrate I get the following error.
SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (localhost) (severity 9) (SQL: select * from sys.sysobjects where id = object_id(migrations) and xtype in ('U', 'V'))
I have tried using 127.0.0.1 and 0.0.0.0 and also the docker container name of the MS SQL Server container (sql1). All give slight variations of the same error with just the host name swapped out.
I also tried to define the port in the docker-compose.yaml
ports:
- '${APP_PORT:-80}:80'
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
- '1433:1433'
This results in the sail container not starting as the port is already bound (MS SQL Server container).
Am I missing a part of the setup as I have looked extensively online and there is not much information on this error?
Try this:
FORWARD_DB_PORT=3313 ./vendor/bin/sail up -d
Related
https://github.com/judge0/judge0
#Dockerfile
FROM judge0/compilers:1.4.0 AS production
ENV JUDGE0_HOMEPAGE "https://judge0.com"
LABEL homepage=$JUDGE0_HOMEPAGE
ENV JUDGE0_SOURCE_CODE "https://github.com/judge0/judge0"
LABEL source_code=$JUDGE0_SOURCE_CODE
ENV JUDGE0_MAINTAINER "Herman Zvonimir Došilović <hermanz.dosilovic#gmail.com>"
LABEL maintainer=$JUDGE0_MAINTAINER
ENV PATH "/usr/local/ruby-2.7.0/bin:/opt/.gem/bin:$PATH"
ENV GEM_HOME "/opt/.gem/"
RUN apt-get update && \
apt-get install -y --no-install-recommends \
cron \
libpq-dev \
sudo && \
rm -rf /var/lib/apt/lists/* && \
echo "gem: --no-document" > /root/.gemrc && \
gem install bundler:2.1.4 && \
npm install -g --unsafe-perm aglio#2.3.0
ENV VIRTUAL_PORT 2358
EXPOSE $VIRTUAL_PORT
WORKDIR /api
COPY Gemfile* ./
RUN RAILS_ENV=production bundle
COPY cron /etc/cron.d
RUN cat /etc/cron.d/* | crontab -
COPY . .
ENTRYPOINT ["/api/docker-entrypoint.sh"]
CMD ["/api/scripts/server"]
ENV JUDGE0_VERSION "1.13.0"
LABEL version=$JUDGE0_VERSION
FROM production AS development
ARG DEV_USER=judge0
ARG DEV_USER_ID=1000
RUN apt-get update && \
apt-get install -y --no-install-recommends \
tmux \
vim && \
useradd -u $DEV_USER_ID -m -r $DEV_USER && \
echo "$DEV_USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
USER $DEV_USER
CMD ["sleep", "infinity"]
I have create a Laravel Project & React Scaffolding, it means React as UI.
Before this project, i have use both Libraries as two different, for example App-frontend(React) and App-backend(Laravel).
But now i have create only one App and it will run on one Container. My Container what i have used before for the App-backend is this one;
FROM php:8.0.10-fpm-alpine
LABEL Maintainer="me" \
Description="Docker container with Nginx 1.15 & PHP-FPM 7.4 based on Alpine Linux. Nginx Confg Ready for Laravel/Lumen"
ENV BUILD_DEPS \
cmake \
autoconf \
g++ \
gcc \
make \
pcre-dev \
gmp-dev \
zip \
libzip-dev \
imagemagick-dev
RUN apk update && apk add --no-cache --virtual .build-deps $BUILD_DEPS $PHPIZE_DEPS
RUN set -ex && apk --no-cache add sudo
RUN apk --no-cache add nginx supervisor curl postgresql-dev libuv-dev openldap-dev ssmtp libxml2-dev
RUN docker-php-ext-install mysqli pdo_mysql pgsql pdo_pgsql
RUN apk add --no-cache libpng libpng-dev && docker-php-ext-install gd && apk del libpng-dev
RUN docker-php-ext-configure zip
RUN docker-php-ext-install zip
#Install Locales
ENV MUSL_LOCALE_DEPS musl-dev gettext-dev libintl
ENV MUSL_LOCPATH /usr/share/i18n/locales/musl
RUN apk add --no-cache \
$MUSL_LOCALE_DEPS \
&& wget https://gitlab.com/rilian-la-te/musl-locales/-/archive/master/musl-locales-master.zip \
&& unzip musl-locales-master.zip \
&& cd musl-locales-master \
&& cmake -DLOCALE_PROFILE=OFF -D CMAKE_INSTALL_PREFIX:PATH=/usr . && make && make install \
&& cd .. && rm -r musl-locales-master
# Add Envsubst
ENV TZ="Europe/Berlin" \
RUNTIME_DEPS="libintl"
RUN apk add --update $RUNTIME_DEPS \
&& apk add --virtual build_deps gettext \
&& cp /usr/bin/envsubst /usr/local/bin/envsubs \
# Add default timezone
&& apk add tzdata \
&& cp /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo "${TZ}" > /etc/timezone
# Configure nginx
COPY .deploy/nginx.conf /nginx.conf
# Configure PHP-FPM
COPY .deploy/fpm-pool.conf /usr/local/etc/php-fpm.d/zzz_custom.conf
COPY .deploy/php.ini /usr/local/etc/php/conf.d/laravel_custom.ini
# Configure supervisord
COPY .deploy/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Configure ssmtp config
COPY .deploy/ssmtp.conf /etc/ssmtp/ssmtp.conf
# Configure Cron Job for Scheduler
#COPY .deploy/scheduler /var/www/html/scheduler
#RUN chmod +x /var/www/html/scheduler
COPY .deploy/crontab /etc/crontabs/root
RUN chmod 0644 /etc/crontabs/root
# Add application
WORKDIR /var/www/html
COPY src/. /var/www/html/
RUN chown -R www-data:www-data /var/www/html/storage/
RUN chown -R www-data:www-data /var/www/html/bootstrap/cache
RUN sudo chmod -R 777 /var/www/html/storage/
RUN sudo chmod -R 777 /var/www/html/bootstrap/cache
# RUN php artisan cache:clear
# RUN php artisan config:cache && php artisan view:cache
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
Now i need help to add the Docker command for the React to run and copy in the src where it run. Can you help me please?
I have some project in docker. When i recreating docker app, docker still deleting old databases in localhost. I did not find any solution on internet. Is there someone who knows how this problem solved?
Thanks for the responding
There is my docker file
FROM php:7.2-apache
ENV DOCKER=1
ENV MASTER_URL_DOCKERFILE='http://website/'
RUN docker-php-ext-install mysqli pdo_mysql
RUN apt-get update -y && apt-get install -y \
libpng-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev libxpm-dev \
libfreetype6-dev
RUN docker-php-ext-configure gd \
--with-gd \
--with-webp-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-xpm-dir \
--with-freetype-dir
RUN docker-php-ext-install gd
RUN docker-php-ext-install calendar && docker-php-ext-configure calendar
RUN a2enmod rewrite
RUN ln -s /etc/apache2/mods-available/expires.load /etc/apache2/mods-enabled/
COPY core /var/www/core/
COPY chainway/src /var/www/html/
COPY chainway/docker/app/ /usr/local/bin/
RUN service apache2 restart
And there is how i running containers
#!/bin/bash
DIR=$(dirname $0)
cd $DIR
wget –V
wget -O "$DIR/docker/db/dump.sql" "http://website/senddatabasetolocalhost.php?auth=authkey"
docker-compose stop
docker-compose build
docker-compose up -d
You will have to use a volumes in docker-compose.yml like this :
volumes:
- $PWD/my_sql:/var/lib/mysql
You can store your db data using volumes.
Add to your docker-compose.yml file in mysql section:
mysql:
volumes:
- db_data:/var/lib/mysql
And to the end of the file:
volumes:
db_data:
I am developing a python web server in Google App Engine.
I want to debug it in VScode so I want to get the Dockerfile for the latest python 3 version in the gcr.io/google-appengine/python
Where do I get it?
Here is the Dockerfile you can use:
FROM gcr.io/google-appengine/python
# Create a virtualenv for dependencies. This isolates these packages from
# system-level packages.
# Use -p python3 or -p python3.7 to select python version. Default is version 2.
RUN virtualenv /env
# Setting these environment variables are the same as running
# source /env/bin/activate.
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
# Copy the application's requirements.txt and run pip to install all
# dependencies into the virtualenv.
ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt
# Add the application source code.
ADD . /app
WORKDIR /app
# Run a WSGI server to serve the application. gunicorn must be declared as
# a dependency in requirements.txt.
ENTRYPOINT ["gunicorn", "-b", ":8080", "server:app"]
You can also look at the Github Repository
This is the github repo of the Python Runtime for App Engine Flex, in that repository you can find the Dockerfile and all the Scripts to create an Docker container similar than the used on App Engine Flex
# The Google App Engine base image is debian (jessie) with ca-certificates
# installed.
# Source: https://github.com/GoogleCloudPlatform/debian-docker
FROM ${OS_BASE_IMAGE}
ADD resources /resources
ADD scripts /scripts
# Install Python, pip, and C dev libraries necessary to compile the most popular
# Python libraries.
RUN /scripts/install-apt-packages.sh
# Setup locale. This prevents Python 3 IO encoding issues.
ENV LANG C.UTF-8
# Make stdout/stderr unbuffered. This prevents delay between output and cloud
# logging collection.
ENV PYTHONUNBUFFERED 1
RUN wget https://storage.googleapis.com/python-interpreters/latest/interpreter-3.4.tar.gz && \
wget https://storage.googleapis.com/python-interpreters/latest/interpreter-3.5.tar.gz && \
wget https://storage.googleapis.com/python-interpreters/latest/interpreter-3.6.tar.gz && \
wget https://storage.googleapis.com/python-interpreters/latest/interpreter-3.7.tar.gz && \
tar -xzf interpreter-3.4.tar.gz && \
tar -xzf interpreter-3.5.tar.gz && \
tar -xzf interpreter-3.6.tar.gz && \
tar -xzf interpreter-3.7.tar.gz && \
rm interpreter-*.tar.gz
# Add Google-built interpreters to the path
ENV PATH /opt/python3.7/bin:/opt/python3.6/bin:/opt/python3.5/bin:/opt/python3.4/bin:$PATH
RUN update-alternatives --install /usr/local/bin/python3 python3 /opt/python3.7/bin/python3.7 50 && \
update-alternatives --install /usr/local/bin/pip3 pip3 /opt/python3.7/bin/pip3.7 50
# Upgrade pip (debian package version tends to run a few version behind) and
# install virtualenv system-wide.
RUN /usr/bin/pip install --upgrade -r /resources/requirements.txt && \
/opt/python3.4/bin/pip3.4 install --upgrade -r /resources/requirements.txt && \
rm -f /opt/python3.4/bin/pip /opt/python3.4/bin/pip3 && \
/opt/python3.5/bin/pip3.5 install --upgrade -r /resources/requirements.txt && \
rm -f /opt/python3.5/bin/pip /opt/python3.5/bin/pip3 && \
/opt/python3.6/bin/pip3.6 install --upgrade -r /resources/requirements.txt && \
rm -f /opt/python3.6/bin/pip /opt/python3.6/bin/pip3 && \
/opt/python3.7/bin/pip3.7 install --upgrade -r /resources/requirements.txt && \
rm -f /opt/python3.7/bin/pip /opt/python3.7/bin/pip3 && \
/usr/bin/pip install --upgrade -r /resources/requirements-virtualenv.txt
# Setup the app working directory
RUN ln -s /home/vmagent/app /app
WORKDIR /app
# Port 8080 is the port used by Google App Engine for serving HTTP traffic.
EXPOSE 8080
ENV PORT 8080
# The user's Dockerfile must specify an entrypoint with ENTRYPOINT or CMD.
CMD []
I was unable to connect to a MS-SQL server via Microsoft's ODBC driver for Linux. Error messages below:
isql mydsn myuser mypw -v
[01000][unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0' : file not found
The message above isn't telling the whole story though. Let's see what ldd can tell us:
ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0)
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0)
[...]
(I'm installing this on a Docker image so that Caravel can connect to MS-SQL databases - see Dockerfile, Docker image for Caravel)
The commands below will install the correct version of libstdc++.so.6 (based on this answer):
echo 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main' > \
/etc/apt/sources.list.d/ubuntu-toolchain-r-test-trusty.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F
apt-get update -y
apt-get upgrade -y
apt-get dist-upgrade -y
So if you're starting from scratch on ubuntu 14.04, these commands will install UnixODBC, Microsoft SQL Server ODBC driver for Linux and all required dependencies:
echo 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main' > \
/etc/apt/sources.list.d/ubuntu-toolchain-r-test-trusty.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F && \
apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y && \
apt-get install -y build-essential libssl-dev libffi-dev \
curl ca-certificates libgss3 && \
locale-gen en_US.utf8 && dpkg-reconfigure locales
mkdir -p /tmp/ms-sql && (cd /tmp/ms-sql && curl 'https://download.microsoft.com/download/2/E/5/2E58F097-805C-4AB8-9FC6-71288AB4409D/msodbcsql-13.0.0.0.tar.gz' \
-H 'Referer: https://www.microsoft.com/en-us/download/confirmation.aspx?id=50419' --compressed | \
tar --strip-components=1 -xzv && \
sed -ri -e 's/wget/curl/g' -e's/(\s*)\$\(curl[^)]+\)/\1curl -fsSL "$dm_url" -o "$dm_package_path"/' \
-e '/make install/,$ d' build_dm.sh && echo '(cd $tmp/$dm_dir && make install)' >> build_dm.sh && \
echo YES | ./build_dm.sh --accept-warning --libdir=/usr/lib/x86_64-linux-gnu && \
./install.sh install --accept-license) && \
sed -rie 's/\[.+SQL Server\]/[MS-SQL]/' /etc/odbcinst.ini