I have installed:
https://laradock.io
When I run this command:
docker-compose exec --user=laradock workspace bash php project1/artisan preset none
I have error:
/usr/bin/php: /usr/bin/php: cannot execute binary file
My file/folder structure:
- laradock
- project1/public
How can I can run this command?
You should remove "bash" from your command.
Run this:
docker-compose exec --user=laradock workspace php project1/artisan preset none
Related
I am following this tutorial,
I installed Docker and WSL2(Ubuntu 20.04.4 LTS) on my windows system, as shown in image below,
When i am trying to run Laravel project using command,
./vendor/bin/sail up
Why i am getting error no such file or directory found?
Instead of:
./vendor/bin/sail up ❌
Use this:
bash ./vendor/laravel/sail/bin/sail up ✅
composer update && npm install worked for me
This worked for me:
Step 1
In your terminal, run this to open your .bash_profile file :
nano ~/.bash_profile
And paste this :
if [ -r ~/.bashrc ]; then
source ~/.bashrc
fi
Exit and save the modification.
Step 2
Still in your terminal, run this to open your
.bashrc file :
nano ~/.bashrc
And paste this :
alias sail='bash vendor/bin/sail'
Exit and save the modification.
Step 3
You can now open any Laravel project using Sail and write the following command to start it :
sail up
Or to run it on background:
sail up -d
I'm using Ubuntu 20.04 on WSL2
I have a Jenkins pipeline just for learning purposes, which should build a Laravel app via docker-compose. The "docker-compose --build" step is working fine, but next it is running "docker-compose run --rm composer update", which then stops, no error or output.
When I run the command manually after accessing the server via SSH, the command runs with no issues.
Composer service in docker-compose file:
composer:
build:
context: .
dockerfile: composer.dockerfile
container_name: composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
depends_on:
- php
user: laravel
entrypoint: ['composer', '--ignore-platform-reqs']
networks:
- laravel
Build step in jenkinsfile:
stage('Build') {
steps {
echo 'Building..'
sh 'chmod +x scripts/jenkins-build.sh'
sh './scripts/jenkins-build.sh'
}
}
Command in shell script:
print "Building docker app"
sudo docker-compose up -d --build site # works fine
sudo chown jenkins -R ./
print "Running composer"
sudo docker-compose run --rm composer update # hangs in jenkins but works in cmd?
View in Jenkins:
Same command working on same server, via cmd:
I know there are some bad practices in here, but this is just for learning purposes. Jenkins server is running Ubuntu 20.04 on AWS EC2 instance.
In the end I resorted to installing composer directly into my PHP docker image. Therefore instead of running the composer service, I now use docker exec php composer update.
From what I can see, any services that were used via docker-compose run did not work in the Jenkins pipeline. In my case, these were all services that were only running whilst performing some action (like composer update), so maybe that is why Jenkins did not like it.
This question already has answers here:
How to source a script with environment variables in a docker build process?
(4 answers)
Closed 3 years ago.
.env file is in project root.
I am using a docker file as follows
FROM alpine:3.7
WORKDIR /app
COPY . /app
RUN apk update && apk add build-base python3 python3-dev --no-cache bash && \
pip3 install --upgrade pip && \
pip3 install --trusted-host pypi.python.org --no-cache-dir -e. && \
./scripts/install.sh
EXPOSE 5000 3306
CMD ["myserver", "run"]
and the install.sh file as follows
#!/usr/bin/env bash
source .env
When I log in to the docker container I noticed that the .env file not getting sourced. How ever .env file is in the folder. How to source the .env file in docker container by using the docker file?
RUN just effect in build stage, so you source will never affect container which is run time. You should do source in CMD or ENTRYPOINT which will run in container run time, write a entrypoint.sh for your project. Something like this
Dockerfile:
ENTRYPOINT ["docker-entrypoint.sh"]
docker-entrypoint.sh:
source .env
my_server run
And, use ENV in dockerfile is another way which will affect the runtime container.
I have created an image from the following Dockerfile.
FROM alpine
WORKDIR /usr/src/app
RUN apk add nodejs-current
RUN apk add nodejs-npm
RUN npm install pm2 -g
COPY process.yaml .
CMD pm2 start process.yaml --no-daemon --log-date-format 'DD-MM
HH:mm:ss.SSS'
process.yaml looks like this:
- script: ./run-services.sh
watch : false
But run-services.sh does not run in my docker. What is the problem?
The problem is that in alpine the bash is not installed by default. pm2 runs bash scripts files by bash command. so there is two way to solve the problem:
Changing default pm2 interpreter from bash to /bin/sh
- script: ./run-services.sh
interpreter: /bin/sh
watch : false
Installing bash in alpine. So the Dockerfile changes as following:
FROM alpine
RUN apk update && apk add bash
WORKDIR /usr/src/app
RUN apk add nodejs-current
RUN apk add nodejs-npm
RUN npm install pm2 -g
COPY process.yaml .
CMD pm2 start process.yaml --no-daemon --log-date-format 'DD-MM
HH:mm:ss.SSS'
I am following the composer developer Tutorial: https://hyperledger.github.io/composer/tutorials/developer-guide.html
Everything worked till the point when I am running from the command line:
$ composer archive create -a dist/my-network.bna --sourceType dir --sourceName .
-bash: fds: command not found
The composer command was not found. When built by npm install the script can execute the composer command within the package.json
Next I installed php composer from: https://getcomposer.org - Which might be the wrong package?
$ composer network deploy
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "network" is not defined.
My 2 questions: is this the right package, if not how can I remove it safely?
Furthermore, how can I execute the composer command.
You need to npm install -g composer-cli -- please refer to the documentation.