tzdata freeze docker build Swfit image - swift

While run docker build to build a swift image, tzdata will stop the process. It prompt to choose a location, but no reaction after I enter the number .
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.
1. Africa 4. Australia 7. Atlantic 10. Pacific 13. Etc
2. America 5. Arctic 8. Europe 11. SystemV
3. Antarctica 6. Asia 9. Indian 12. US
Geographic area:
my Dockefile is :
FROM ubuntu:18.04
LABEL maintainer="Swift Infrastructure <swift-infrastructure#swift.org>"
LABEL Description="Docker Container for the Swift programming language"
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y \
git \
curl \
cmake \
wget \
ninja-build \
clang \
python \
uuid-dev \
libicu-dev \
icu-devtools \
libbsd-dev \
libedit-dev \
libxml2-dev \
libsqlite3-dev \
swig \
libpython-dev \
libncurses5-dev \
pkg-config \
libblocksruntime-dev \
libcurl4-openssl-dev \
systemtap-sdt-dev \
tzdata \
rsync && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Vapor setup
RUN /bin/bash -c "$(wget -qO- https://apt.vapor.sh)"
# Install vapor and clean
RUN apt-get install swift vapor -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN vapor --help
It is work normally before I reset the Docker. Where is my mistake?

Prevent tzdata for asking by adding ARG DEBIAN_FRONTEND=noninteractive to the Dockerfile.

Related

The repository 'http://apt.postgresql.org/pub/repos/apt stretch-pgdg Release' does not have a Release file?

I have an error when I am building my Docker containers. It seems that there are problems with Postgres Stretch for Debian. I saw that Debian strech was removed and no longer supported.
I found similar problem here: The repository 'http://apt.postgresql.org/pub/repos/apt stretch-pgdg Release' does not have a Release file but i didn't managed to solve my problem.
Here is an error:
W: The repository 'http://apt.postgresql.org/pub/repos/apt stretch-pgdg Release' does not have a Release file.
E: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/stretch-pgdg/11/binary-amd64/Packages 404 Not Found [IP: 147.75.85.69 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
ERROR: Service 'db' failed to build: The command '/bin/sh -c apt-get update && apt-get install dos2unix && apt-get clean' returned a non-zero code: 100
And here's part of my Dockerfile that I'm trying to run:
FROM debian:jessie
MAINTAINER Open Knowledge
# Install required system packages
RUN apt-get -q -y update \
&& DEBIAN_FRONTEND=noninteractive apt-get -q -y upgrade \
&& apt-get -q -y install \
curl \
python-dev \
python-pip \
python-virtualenv \
python-wheel \
libpq-dev \
libxml2-dev \
libxslt-dev \
libgeos-dev \
libssl-dev \
libxslt-dev \
libgeos-dev \
libssl-dev \
libffi-dev \
postgresql-client \
build-essential \
git-core \
vim \
wget \
&& apt-get -q clean \
&& apt-get install -y dos2unix
Do you maybe know what I should add or remove in my Dockerfile file to solve this problem?
Thanks in advance
Debian stretch is no longer supported
You could use this deb package instead:
deb https://apt-archive.postgresql.org/pub/repos/apt stretch-pgdg main

AWS Lambda - Swift Operation not permitted

I am trying to compile Swift code via AWS Lambda.
Therefore I am using an Ubuntu 18.04 Image as base.
The Swift Version is 5.0.1.
When the image is executed locally, it works fine.
When I try to execute it in AWS Lambda, I get the following error:
/usr/bin/ld.gold: fatal error: /tmp/project/src/a.out: Operation not
permitted\nclang-7: error: linker command failed with exit code 1 (use
-v to see invocation)
I think that the problem is caused by the read-only aws lambda container, that only allows to write into the /tmp/ folder.
Do you know how to fix this error? It seems that swift needs permissions for folders, it doesnt have permission for?
Dockerfile
FROM ubuntu:18.04
# install clang
RUN apt-get update
RUN apt-get install -y clang
# install wget
RUN apt-get install -y wget
# install swift dependencies
RUN apt-get install -y libcurl3 libpython2.7 libpython2.7-dev
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y --no-install-recommends \
binutils \
git \
libc6-dev \
libcurl4 \
libedit2 \
libgcc-5-dev \
libpython2.7 \
libsqlite3-0 \
libstdc++-5-dev \
libxml2 \
pkg-config \
tzdata \
zlib1g-dev \
libbsd-dev
RUN apt-get install -y libicu-dev
# install swift 5.0.1
RUN wget https://swift.org/builds/swift-5.0.1-release/ubuntu1804/swift-5.0.1-RELEASE/swift-5.0.1-RELEASE-ubuntu18.04.tar.gz RUN tar xzf swift-5.0.1-RELEASE-ubuntu18.04.tar.gz RUN mv swift-5.0.1-RELEASE-ubuntu18.04 /usr/lib/swift RUN echo "export PATH=/usr/lib/swift/usr/bin:$PATH" >> ~/.bashrc
RUN . ~/.bashrc
RUN chmod -R o+r /usr/lib/swift
This is the command executed in the AWS-Lambda handler function:
swiftc hello_world.swift -o a.out
hello_world.swift
print("Hello World!")
Your output must be set in tmp folder
swiftc hello_world.swift -o /tmp/a.out

gcloud install kubectl fails on MacBook M1

I modified the following Dockerfile to use arm binaries so it works on my M1 MacBook Pro, the original works fine on a MacBook Pro i5.
FROM --platform=linux/arm64/v8 alpine:latest
RUN apk --no-cache add \
ack~3 \
bash~5 \
curl~7 \
htop~3 \
jq~1.6 \
make~4.3 \
nano~5 \
python3~3 \
tree~1.8 \
util-linux~2
ARG CLOUD_SDK_VERSION=367.0.0
ENV PATH /google-cloud-sdk/bin:$PATH
RUN curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${CLOUD_SDK_VERSION}-darwin-arm.tar.gz && \
tar xzf google-cloud-sdk-${CLOUD_SDK_VERSION}-darwin-arm.tar.gz && \
rm google-cloud-sdk-${CLOUD_SDK_VERSION}-darwin-arm.tar.gz && \
gcloud components list && \
gcloud components install kubectl
The last step gcloud components install kubectl fails with the following error.
WARNING: The platform specific binary does not exist for components
[kubectl].
ERROR: (gcloud.components.install) The following components
are unknown [kubectl].
I changed the platform to amd64 and it worked!
FROM --platform=linux/amd64 alpine:latest

How to install pgsql driver on docker php:7.1-apache?

I have an API Platform project with a postgresql DB and I can't find how to enable pdo pgsql driver with docker..
Here is my docker file :
FROM php:7.1-apache
# PHP extensions
ENV APCU_VERSION 5.1.7
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libicu-dev \
zlib1g-dev \
libpq-dev \
libzip-dev \
libpcre3-dev \
ssmtp vim git cron zip \
&& docker-php-ext-install \
pdo \
pdo_pgsql \
zip
# Apache config
RUN a2enmod rewrite
ADD docker/apache/vhost.conf /etc/apache2/sites-available/000-default.conf
# Add the application
ADD . /app
WORKDIR /app
# Install composer
RUN ./docker/composer.sh \
&& mv composer.phar /usr/bin/composer \
&& composer global require "hirak/prestissimo:^0.3"
RUN usermod -u 1000 www-data
#RUN chown -R www-data:www-data /app/var/cache /app/var/logs /app/var/sessions
CMD ["/app/docker/start.sh"]
and here my docker-composer.yml file
web:
container_name: web-api-front
build: .
environment:
SYMFONY_ENV: dev
volumes:
- .:/app
ports:
- 8084:80
psql:
container_name: psql-api-front
image: postgres
environment:
POSTGRES_PASSWORD: ''
POSTGRES_USER: dbuser
POSTGRES_DB: dbname
ports:
- "5433:5432"
volumes:
- ./docker/sql:/var/sql
I've tryed a lot of websites but I still can't find a way to enable pgsql..
When I do
var_dump(PDO::getAvailableDrivers());
I only have
array(2) { [0]=> string(6) "sqlite" [1]=> string(5) "mysql" }
Also, when I run
docker-compose up
I have this in my log, i'm not sure about what this mean
psql-api-front | LOG: database system was shut down at 2017-08-01 08:18:57 UTC
psql-api-front | LOG: MultiXact member wraparound protections are now enabled
psql-api-front | LOG: database system is ready to accept connections
psql-api-front | LOG: autovacuum launcher started
What am I doing wrong ?
That means that PSQL is working properly but in order to apache to work properly you will need to add the psql libraries and drivers :
FROM php:7.1-apache
# PHP extensions
ENV APCU_VERSION 5.1.7
RUN buildDeps=" \
libicu-dev \
zlib1g-dev \
libsqlite3-dev \
libpq-dev \
" \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
$buildDeps \
libicu52 \
zlib1g \
sqlite3 \
git \
php5-pgsql \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-install \
intl \
mbstring \
pdo_mysql \
pdo_pgsql \
pdo \
pgsql \
zip \
pdo_sqlite \
&& apt-get purge -y --auto-remove $buildDeps
RUN pecl install \
apcu-$APCU_VERSION \
xdebug \
&& docker-php-ext-enable xdebug \
&& docker-php-ext-enable --ini-name 05-opcache.ini \
opcache \
&& docker-php-ext-enable --ini-name 20-apcu.ini \
apcu
ARG SYMFONY_ENV=dev
ENV SYMFONY_ENV=dev
RUN if [ "$SYMFONY_ENV" -ne "dev" ]; then \
sed -i '1 a xdebug.remote_enable=1' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
sed -i '1 a xdebug.remote_handler=dbgp' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
sed -i '1 a xdebug.remote_autostart=0' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
sed -i '1 a xdebug.remote_connect_back=1 ' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
sed -i '1 a xdebug.remote_port=9001' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
sed -i '1 a xdebug.remote_log=/var/log/xdebug_remote.log' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
fi;
# Apache config
RUN a2enmod rewrite
ADD docker/apache/vhost.conf /etc/apache2/sites-available/000-default.conf
# PHP config
ADD docker/php/php.ini /usr/local/etc/php/php.ini
# Add the application
ADD . /app
WORKDIR /app
RUN chmod +x /app/docker/composer.sh
# Install composer
RUN /app/docker/composer.sh \
&& mv composer.phar /usr/bin/composer \
&& composer global require "hirak/prestissimo:^0.3"
ENV PATH="$PATH:$HOME/.composer/vendor/bin"
# to define
ARG INSTALL_DEP=true
RUN if [ -n "$INSTALL_DEP" ]; then \
if [ "$SYMFONY_ENV" -ne "prod" ]; then \
composer install --prefer-dist --no-scripts --no-dev --no-progress --no-suggest --optimize-autoloader --classmap-authoritative && composer run-script continuous-pipe; \
else \
composer install -o --no-interaction --prefer-dist --no-scripts && composer run-script continuous-pipe; \
fi; \
fi;
# Remove cache and logs if some and fixes permissions
RUN rm -rf var/cache/* && rm -rf var/logs/* && rm -rf var/sessions/* && chmod a+r var/ -R
# Apache gets grumpy about PID files pre-existing
RUN rm -f /var/run/apache2/apache2.pid
RUN a2enmod ssl
EXPOSE 443
CMD ["/app/docker/apache/run.sh"]
This should be working properly and you could compare with ur existing configuration.

How to run sql script before the application launches in docker

I'm deploying the project with Asp.net Core, PostgreSql and Docker in Windows 10 (no PostgreSql installed). So I have to run sql script to update data before the application launches (for registering a singleton dependency injection).
The content of my Dockerfile as following:
# TODO use official docker image
FROM microsoft/dotnet:1.1.0-sdk-projectjson
# Install .NET CLI dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
automake \
bzip2 \
file \
g++ \
gcc \
imagemagick \
libbz2-dev \
libc6-dev \
libcurl4-openssl-dev \
libdb-dev \
libevent-dev \
libffi-dev \
libgdbm-dev \
libgeoip-dev \
libglib2.0-dev \
libjpeg-dev \
libkrb5-dev \
liblzma-dev \
libmagickcore-dev \
libmagickwand-dev \
libmysqlclient-dev \
libncurses-dev \
libpng-dev \
libpq-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libtool \
libwebp-dev \
libxml2-dev \
libxslt-dev \
libyaml-dev \
make \
patch \
xz-utils \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables
ENV ASPNETCORE_URLS="http://*:5000"
ENV ASPNETCORE_ENVIRONMENT="Development"
# Copy files to app directory
COPY . /app
# Set working directory
WORKDIR /app
# Restore NuGet packages
RUN ["dotnet", "restore"]
# Build app
RUN ["dotnet", "build"]
#dotnet ef migrations add InitialCreate
RUN ["dotnet", "ef", "migrations", "add", "InitialCreate"]
# Open up port
EXPOSE 5000
CMD chmod +x ./docker-start.sh
CMD bash ./docker-start.sh
And here is the content of docker-start.sh:
#!/bin/bash
set -e
# How to apply migrations
dotnet ef database update
# I would like to run sql file at here"
psql -h postgres --username postgres -d POSTGRES_USER -a -f /app/static.sql
# Start web app
echo "Starting web app"
dotnet run
How can I do that? Thanks advanced.
I have just found a solution for this. I missed postgresql-client. We will be need to install postgresql-client as using psql to run the sql script from Dockerfile.
So Dockerfile should be changed:
# TODO use official docker image
FROM microsoft/dotnet:1.1.0-sdk-projectjson
# Install .NET CLI dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
automake \
bzip2 \
file \
g++ \
gcc \
imagemagick \
libbz2-dev \
libc6-dev \
libcurl4-openssl-dev \
libdb-dev \
libevent-dev \
libffi-dev \
libgdbm-dev \
libgeoip-dev \
libglib2.0-dev \
libjpeg-dev \
libkrb5-dev \
liblzma-dev \
libmagickcore-dev \
libmagickwand-dev \
libmysqlclient-dev \
libncurses-dev \
libpng-dev \
libpq-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libtool \
libwebp-dev \
libxml2-dev \
libxslt-dev \
libyaml-dev \
make \
patch \
xz-utils \
zlib1g-dev \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*
# Install netcat so that we can ping the database server until it
RUN apt-get update -qq \
&& apt-get install -y netcat \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables
ENV ASPNETCORE_URLS="http://*:5000"
ENV ASPNETCORE_ENVIRONMENT="Development"
ENV DB_HOSTNAME="posgres"
# Copy files to app directory
COPY . /app
# Set working directory
WORKDIR /app
# Restore NuGet packages
RUN ["dotnet", "restore"]
# Build app
RUN ["dotnet", "build"]
#dotnet ef migrations add InitialCreate
RUN ["dotnet", "ef", "migrations", "add", "InitialCreate"]
# Open up port
EXPOSE 5000
CMD chmod +x ./docker-start.sh
CMD bash ./docker-start.sh
Thanks.