install laravel9.1 by sail docker-compose cant build - laravel

After using sail build --no-cache command, apt-key is stuck。
mysql uses an image, skipping
redis uses an image, skipping
meilisearch uses an image, skipping
mailhog uses an image, skipping
selenium uses an image, skipping
Building laravel.test
[+] Building 3654.7s (7/15)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.39kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:21.10 0.7s
=> [ 1/11] FROM docker.io/library/ubuntu:21.10#sha256:cc8f713078bfddfe9ace41e29eb73298f52b2c958ccacd1b376b9378e20906ef 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 99B 0.0s
=> CACHED [ 2/11] WORKDIR /var/www/html 0.0s
=> [ 3/11] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone 0.2s
=> [ 4/11] 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 3653.7s
=> => # Updating certificates in /etc/ssl/certs...
=> => # 0 added, 0 removed; done.
=> => # Running hooks in /etc/ca-certificates/update.d...
=> => # done.
=> => # Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
=> => # Executing: /tmp/apt-key-gpghome.itanfA6ojm/gpg.1.sh --homedir /root/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C
please help me,how to solve this problem. thank you very much.

Related

docker-compose fails on RUN sudo gem update --system

Installed docker desktop for windows in a Hyper-V VM running Windows 10 21H2. Have cloned a repository from GitHub using the GitHub desktop. Started a PowerShell as administrator, navigated to the cloned repository location. When I run docker-compose up I get the following error:
[+] Building 3.7s (5/9)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/circleci/ruby:2.7.5-node 3.3s
=> CACHED [1/6] FROM docker.io/circleci/ruby:2.7.5-node#sha256:23d760208eed58ff57f8721d20dcd8c9bc5f9ee8a5293fa14 0.0s
=> ERROR [2/6] RUN sudo gem update --system 0.2s
[2/6] RUN sudo gem update --system:
#0 0.197 sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?
failed to solve: executor failed running [/bin/sh -c sudo gem update --system]: exit code: 1
docker itself installed ok and is running. I've checked all the pre-reqs and can see no reason why this is happening. Has anyone else experienced this?

Laravel install via Docker on WSL2 never stops building

I'm trying to install a fresh Laravel 9 on Windows 10/WSL 2 with Docker. I followed the documentation and once I run the first command it gets stuck during building when it gets to the 4/11 stage, running endlessly until I have to cancel.
Here is what it looks like in the Terminal:
=> [ 4/11] RUN apt-get update && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervis 167.8s
=> => # Processing triggers for ca-certificates (20211016ubuntu0.22.04.1) ...
=> => # Updating certificates in /etc/ssl/certs...
=> => # 0 added, 0 removed; done.
=> => # Running hooks in /etc/ca-certificates/update.d...
=> => # done.
=> => # gpg: keybox '/root/.gnupg/pubring.kbx' created
I used Unbuntu and Docker is fresh install. I don't understand what seems to be the problem here.
Honestly I didn't try much, I have no idea what the issue is...

How to connect memcached laravel and docker?

I have created the memcached container in docker
docker-compose.yml:
#store cache
memcached:
image: memcached
container_name: memcached
ports:
- "11211:11211"
.env
MEMCACHED_HOST=memcached
MEMCACHED_PORT=11211
CACHE_DRIVER=memcached
and in my config/cache.php file section stores as follows:
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
In a method I have made the following example:
$user = \Cache::remember('user', 60, function() {
return \App\Models\User::first();
}); */
$c = new \Memcached();
$c->addServer("memcached", 11211);
var_dump( $c->getAllKeys() );
but I am getting the error:
Error: Class 'Memcached' not found
I don't know if it is a problem in my container, since when I enter the container with this command:
docker-compose exec --user 0 memcached bash
I run the stats command inside the container but I get the error that it has not been found
root#520aaa151216:/# stats
bash: stats: command not found
I have executed:
php artisan cache:clear
composer dump-autoload
however the memcached errors continue.
This is my dockerfile
FROM php:7.3-fpm
LABEL version="1.0"
#install pdftk
RUN mkdir -p /usr/share/man/man1mkdir -p /usr/share/man/man1
# Install dependencies
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libzip-dev \
zip \
locales \
vim \
unzip \
git \
jpegoptim optipng pngquant gifsicle \
curl \
npm \
supervisor \
pdftk
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql bcmath mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
RUN pecl install xdebug-3.0.4 \ && docker-php-ext-enable xdebug
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Copy existing application directory contents
WORKDIR /var/www
ADD ./ /var/www
# install laravel
RUN COMPOSER_MEMORY_LIMIT=-1 composer install
RUN composer dump-autoload
RUN php artisan config:cache
RUN php artisan route:cache
RUN php artisan route:clear
#npm install
#USER root
RUN npm i npm#latest -g
RUN npm install --global yarn
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Copy supervisor configuration
ADD docker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
#Expose ports
EXPOSE 9000
EXPOSE 9003
#Run commands
CMD ["/usr/bin/supervisord"]
Found in this link: https://github.com/devilbox/docker-php-fpm/blob/master/Dockerfiles/mods/Dockerfile-7.3
I have added in my dockerfile:
# Install Memcached for php 7
RUN set -eux \
&& pecl install memcached \
&& docker-php-ext-enable memcached \
&& true

Problem with building Docker image from Dockerfile

my task is to create a docker container from my own Dockerfile using ubuntu:18.10 and run pdflatex in this container. My system is MacOs, my Dockerfile looks like this:
FROM ubuntu:18.10
RUN apt-get update && apt-get install texlive-fonts-recommended \
texlive-generic-recommended \
texlive-latex-extra \
texlive-fonts-extra \
dvipng \
texlive-latex-recommended \
texlive-base \
texlive-pictures \
texlive-lang-cyrillic \
texlive-science \
cm-super \
texlive-generic-extra
CMD ["bash"]
I input this line in Terminal, while being in the directory, where the Dockerfile is:
docker build .
The output I get is this:
[+] Building 1.7s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 455B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:18.10 0.0s
=> CACHED [1/2] FROM docker.io/library/ubuntu:18.10 0.0s
=> ERROR [2/2] RUN apt-get update && apt-get install texlive-fonts-recom 1.6s
------
> [2/2] RUN apt-get update && apt-get install texlive-fonts-recommended texlive-generic-recommended texlive-latex-extra texlive-fonts-extra dvipng texlive-latex-recommended texlive-base texlive-pictures texlive-lang-cyrillic texlive-science cm-super texlive-generic-extra:
#5 1.239 Ign:1 http://archive.ubuntu.com/ubuntu cosmic InRelease
#5 1.291 Ign:2 http://archive.ubuntu.com/ubuntu cosmic-updates InRelease
#5 1.343 Ign:3 http://archive.ubuntu.com/ubuntu cosmic-backports InRelease
#5 1.366 Ign:4 http://security.ubuntu.com/ubuntu cosmic-security InRelease
#5 1.394 Err:5 http://archive.ubuntu.com/ubuntu cosmic Release
#5 1.394 404 Not Found [IP: 91.189.88.142 80]
#5 1.447 Err:6 http://archive.ubuntu.com/ubuntu cosmic-updates Release
#5 1.447 404 Not Found [IP: 91.189.88.142 80]
#5 1.482 Err:7 http://security.ubuntu.com/ubuntu cosmic-security Release
#5 1.482 404 Not Found [IP: 91.189.91.39 80]
#5 1.497 Err:8 http://archive.ubuntu.com/ubuntu cosmic-backports Release
#5 1.498 404 Not Found [IP: 91.189.88.142 80]
#5 1.507 Reading package lists...
#5 1.537 E: The repository 'http://archive.ubuntu.com/ubuntu cosmic Release' does not have a Release file.
#5 1.538 E: The repository 'http://archive.ubuntu.com/ubuntu cosmic-updates Release' does not have a Release file.
#5 1.539 E: The repository 'http://security.ubuntu.com/ubuntu cosmic-security Release' does not have a Release file.
#5 1.540 E: The repository 'http://archive.ubuntu.com/ubuntu cosmic-backports Release' does not have a Release file.
------
executor failed running [/bin/sh -c apt-get update && apt-get install texlive-fonts-recommended texlive-generic-recommended texlive-latex-extra texlive-fonts-extra dvipng texlive-latex-recommended texlive-base texlive-pictures texlive-lang-cyrillic texlive-science cm-super texlive-generic-extra]: exit code: 100
As I understand it there is a problem while installing packs for pdflatex, but I don't understand what the error is and how to fix it. Can you tell me what to do?
Default repositories are deprecated.
Replace repositories *.ubuntu.com with old-releases.ubuntu.com in /etc/apt/sources.list with following (This is entire Dockerfile):
FROM ubuntu:18.10
RUN sed -i 's/archive.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
RUN sed -i 's/security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
RUN apt-get update && apt-get install -y texlive-fonts-recommended \
texlive-generic-recommended \
texlive-latex-extra \
texlive-fonts-extra \
dvipng \
texlive-latex-recommended \
texlive-base \
texlive-pictures \
texlive-lang-cyrillic \
texlive-science \
cm-super \
texlive-generic-extra
CMD ["bash"]
Note that I added -y to the apt-get install command because I want to automatically agree to the installation.

How to cache maven repo when building Spring Boot docker image on Jenkins

I'm trying to build docker images for a Spring Boot application (2.3.6.RELEASE) using the spring-boot-maven-plugin build-image goal (buildpacks), but it's downloading the internet everytime! Is there a way to mount the .m2 directory to the buildpack, so it can use dependencies from the cache?
sudo ./mvnw -pl ${PROJECT_NAME} org.springframework.boot:spring-boot-maven-plugin:2.3.6.RELEASE:build-image -DskipTests=true"
I'm using the ecs jenkins plugin (https://plugins.jenkins.io/amazon-ecs/) and binding the .m2 directory and the docker socket:
Update: Ok I think the issue is I'm mounting the .m2 directory to /home/jenkins/.m2, but I'm executing the build-image goal with sudo to give the command access to docker daemon, and the default maven repo location is ~/.m2. If I execute it without sudo I get the following error:
[INFO] Building image 'docker.io/library/tellus-emergency-lighting:dev-SNAPSHOT'
[INFO]
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [13] Permission denied
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [13] Permission denied
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [13] Permission denied
[INFO] Retrying request to {}->docker://localhost:2376
[INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 100%
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.685 s
[INFO] Finished at: 2020-11-23T23:19:19Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.6.RELEASE:build-image (default-cli) on project tellus-emergency-lighting: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.3.6.RELEASE:build-image failed: Connection to the Docker daemon at 'localhost' failed with error "[13] Permission denied"; ensure the Docker daemon is running and accessible: com.sun.jna.LastErrorException: [13] Permission denied -> [Help 1]
Is there some way I can execute it without sudo?
I also tried adding -Dmaven.repo.local=/home/jenkins/.m2, but that didn't seem to help (it still downloads the dependencies again):
sudo ./mvnw -pl ${PROJECT_NAME} org.springframework.boot:spring-boot-maven-plugin:build-image -DskipTests=true -Dmaven.repo.local=/home/jenkins/.m2
Here's my ECS agent dockerfile:
FROM jenkins/inbound-agent as builder
FROM ubuntu:20.04
#################################################
# Inspired by
# https://github.com/cloudbees/java-build-tools-dockerfile/blob/master/Dockerfile
#################################################
#================================================
# Customize sources for apt-get
#================================================
RUN DISTRIB_CODENAME=$(cat /etc/*release* | grep DISTRIB_CODENAME | cut -f2 -d'=') \
&& echo "deb http://archive.ubuntu.com/ubuntu ${DISTRIB_CODENAME} main universe\n" > /etc/apt/sources.list \
&& echo "deb http://archive.ubuntu.com/ubuntu ${DISTRIB_CODENAME}-updates main universe\n" >> /etc/apt/sources.list \
&& echo "deb http://security.ubuntu.com/ubuntu ${DISTRIB_CODENAME}-security main universe\n" >> /etc/apt/sources.list
RUN apt-get update -qqy \
&& apt-get -qqy --no-install-recommends install software-properties-common \
&& add-apt-repository -y ppa:git-core/ppa
#========================
# Miscellaneous packages
# iproute which is surprisingly not available in ubuntu:15.04 but is available in ubuntu:latest
# OpenJDK11
# groff is for aws-cli
# tree is convenient for troubleshooting builds
#========================
RUN apt-get update -qqy \
&& apt-get -qqy --no-install-recommends install \
iproute2 \
openssh-client ssh-askpass\
ca-certificates \
gpg gpg-agent \
openjdk-11-jdk \
tar zip unzip \
wget curl \
git \
build-essential \
less nano tree \
jq \
python3 python3-pip groff \
rsync \
&& apt-get clean
# && sed -i 's/securerandom\.source=file:\/dev\/random/securerandom\.source=file:\/dev\/urandom/' ./usr/lib/jvm/java-11-openjdk-amd64/jre/lib/security/java.security
# Update pip after install
RUN pip3 install --upgrade pip setuptools
RUN pip3 install yq
#==========
# Docker
#==========
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
RUN apt-get -qqy install --no-install-recommends docker-ce docker-ce-cli containerd.io
RUN apt-get update
RUN apt-get install sudo -y
#==========
# Maven
#==========
ENV MAVEN_VERSION 3.6.3
RUN curl -fsSL http://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar xzf - -C /usr/share \
&& mv /usr/share/apache-maven-$MAVEN_VERSION /usr/share/maven \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
#==========
# Gradle
#==========
ENV GRADLE_VERSION 6.5.1
RUN wget -q https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip -P /tmp \
&& unzip -d /opt/gradle /tmp/gradle-${GRADLE_VERSION}-bin.zip \
&& ln -s /opt/gradle/gradle-${GRADLE_VERSION}/bin/gradle /usr/bin/gradle \
&& rm /tmp/gradle-${GRADLE_VERSION}-bin.zip
#========================================
# Add normal user with passwordless sudo
#========================================
RUN useradd jenkins --shell /bin/bash --create-home \
&& usermod -a -G sudo jenkins \
&& echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \
&& echo 'jenkins ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& echo 'jenkins:secret' | chpasswd
#====================================
# AWS CLI
#====================================
RUN pip3 install awscli
# compatibility with CloudBees AWS CLI Plugin which expects pip to be installed as user
RUN mkdir -p /home/jenkins/.local/bin/ \
&& ln -s /usr/local/bin/pip /home/jenkins/.local/bin/pip \
&& chown -R jenkins:jenkins /home/jenkins/.local
#====================================
# Kubernetes CLI
# See https://storage.googleapis.com/kubernetes-release/release/stable.txt
#====================================
RUN curl https://storage.googleapis.com/kubernetes-release/release/v1.19.3/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl && chmod +x /usr/local/bin/kubectl
#==========
# Slave
#==========
COPY --from=builder /usr/local/bin/jenkins-slave /usr/local/bin/jenkins-agent
COPY --from=builder /usr/share/jenkins/agent.jar /usr/share/jenkins/agent.jar
USER root
RUN chmod +x /usr/local/bin/jenkins-agent \
&& ln -s /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-slave
RUN chmod 644 /usr/share/jenkins/agent.jar \
&& ln -sf /usr/share/jenkins/agent.jar /usr/share/jenkins/slave.jar
USER jenkins
ENTRYPOINT ["jenkins-agent"]
There's probably a better way to do it, but I got it working by adding: -Dmaven.repo.local=/home/jenkins/.m2/repository, so:
sudo ./mvnw -pl ${PROJECT_NAME} org.springframework.boot:spring-boot-maven-plugin:2.3.6.RELEASE:build-image -Dmaven.repo.local=/home/jenkins/.m2/repository -DskipTests=true"

Resources