heroku-php-apache2 public/: No such file or directory - symfony

I'm building my symfony app with heroku's buildpack using pack build my_app --builder heroku/buildpacks:20 and this Procfile.
# Procfile
web: heroku-php-apache2 public/
All works greak. Runs on my local docker and AWS.
Running it on Heroku however doesn't work.
This is how I deploy:
docker login -u _ -p $HEROKU_API_KEY $HEROKU_REGISTRY
docker push $HEROKU_LATEST
heroku container:release --app "$HEROKU_APP_NAME" web
But then...
heroku[web.1]: Starting process with command `/cnb/process/web`
app[web.1]: heroku-php-apache2 public/: heroku-php-apache2 public/: No such file or directory
heroku[web.1]: Process exited with status 127
heroku[web.1]: State changed from starting to crashed
I tried all possible path combinations in the Procfile without any success.
I even tried to bypassing the initial error to be able to run my own commands against the app.
# Procfile
web: bash
and than heroku run --app "$HEROKU_APP_NAME" -- heroku-php-apache2 public/
Which has no problems..
Running /app/vendor/bin/heroku-php-apache2 ./public on ⬢ <my-app>... up, run.8454 (Free)
DOCUMENT_ROOT changed to './public/'
Detected 536870912 Bytes of RAM
PHP memory_limit is 128M Bytes
Starting php-fpm with 4 workers...
Starting httpd...
What am I missing?
Edit:
I also pulled the image heroku container:pull --app "$HEROKU_APP_NAME" "$HEROKU_APP_NAME/web" and ran it locally docker run -d -p 80:5000 --name=app $HEROKU_LATEST without any issues.
Edit:
pack inspect-image $HEROKU_LATEST
Inspecting image: ...
REMOTE:
(not present)
LOCAL:
Stack: heroku-20
Base Image:
Reference: ...
Top Layer: sha256:...
Run Images:
heroku/heroku:20-cnb
Buildpacks:
ID VERSION HOMEPAGE
heroku/php 0.0.0 -
heroku/procfile 2.0.0 https://github.com/heroku/procfile-cnb
Processes:
TYPE SHELL COMMAND ARGS WORK DIR
web (default) bash heroku-php-apache2 public/ /workspace

Related

error Back-off restarting failed container in nginx pod

simple use-case to deploy the nginx image using kubernetes
Dockerfile used to create the image. The "./build/" in the dockerfile COPY statement, is the output directory (npm run build) of reactjs code.Just static files in it.
FROM nginx
COPY ./build/ /usr/share/nginx/html/
RUN rm -f /etc/nginx/conf.d/default.conf
COPY ./default.conf /etc/nginx/conf.d/
CMD ["nginx"]
EXPOSE 80
Why is this error in nginx deployment? error is "Back-off restarting failed container".
manually ran the container, but nginx is not running. I could start the nginx manually. Am I missing any configuration in the Dockerfile or in /etc/nginx/conf.d/default.conf file? files are copied and available in github path for reference.
root#desktop:~/github/nginx-app# docker run -it private.registry.corp/company-dev-poc/nginx-cms:001 bash
root#fc7ebd431ae2:/# service nginx status
[FAIL] nginx is not running ... failed!
Use CMD ["nginx", "-g", "daemon off;"]
Also, you do not need to specify the command. CMD and EXPOSE would be defined in the base image - nginx in this case. They need not be defined again.

Docker for Windows building added prefix `/var/lib/docker/tmp/` for COPY?

I've installed Docker for Windows and created a new Asp.net core application with docker support using Visual Studio 2017(I haven't made any change yet). However, docker build reported the following error. Is the Dockerfile correct?
PS C:\source\repos\myProj\ProcessFiles> docker build .
Sending build context to Docker daemon 1.178MB
Step 1/17 : FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
---> 04aae08f15c5
Step 2/17 : WORKDIR /app
---> Using cache
---> 135955e04284
Step 3/17 : EXPOSE 34746
---> Using cache
---> 85fd0075aa42
Step 4/17 : EXPOSE 44398
---> Using cache
---> 7e3d5526f601
Step 5/17 : FROM microsoft/dotnet:2.1-sdk AS build
---> 7c3e298d40ac
Step 6/17 : WORKDIR /src
---> Using cache
---> b395ba27d8f9
Step 7/17 : COPY ProcessFiles/ProcessFiles.csproj ProcessFiles/
COPY failed: stat /var/lib/docker/tmp/docker-builder662645761/ProcessFiles/ProcessFiles.csproj: no such file
or directory
Here is the Dockerfile automatically generated by Visual Studio. The error occurred on the line COPY ProcessFiles/ProcessFiles.csproj ProcessFiles/.
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 34746
EXPOSE 44398
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ProcessFiles/ProcessFiles.csproj ProcessFiles/
RUN dotnet restore ProcessFiles/ProcessFiles.csproj
COPY . .
WORKDIR /src/ProcessFiles
RUN dotnet build ProcessFiles.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish ProcessFiles.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ProcessFiles.dll"]
Here is the Visual Studio output. (The lines about setting AWS were excluded).
Inspecting Dockerfile to figure how to build project and docker image
... Skip building project since it is done as part of Dockerfile
Executing docker build
... invoking 'docker build', working folder 'C:\source\repos\myProj\ProcessFiles, docker file C:\source\repos\myProc\ProcessFiles\Dockerfile, image name processfiles:latest'
... docker build: Sending build context to Docker daemon 1.178MB
... docker build: COPY failed: stat /var/lib/docker/tmp/docker-builder225959758/ProcessFiles/ProcessFiles.csproj: no such file or directory
... docker build: Step 1/17 : FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
... docker build: ---> 04aae08f15c5
... docker build: Step 2/17 : WORKDIR /app
... docker build: ---> Using cache
... docker build: ---> 135955e04284
... docker build: Step 3/17 : EXPOSE 34746
... docker build: ---> Using cache
... docker build: ---> 85fd0075aa42
... docker build: Step 4/17 : EXPOSE 44398
... docker build: ---> Using cache
... docker build: ---> 7e3d5526f601
... docker build: Step 5/17 : FROM microsoft/dotnet:2.1-sdk AS build
... docker build: ---> 7c3e298d40ac
... docker build: Step 6/17 : WORKDIR /src
... docker build: ---> Using cache
... docker build: ---> b395ba27d8f9
... docker build: Step 7/17 : COPY ProcessFiles/ProcessFiles.csproj ProcessFiles/
Error executing "docker build"
Attempting to clean up any ELB resources created for the failed deployment
Unknown error publishing container to AWS
Here are the files in directory C:\source\repos\myProj. The file Dockerfile is under C:\source\repos\myProj\ProcessFile\. Should it be moved one level up?
Mode Name
---- ----
d----- bin
d----- obj
d----- ProcessFiles
-a---- .dockerignore
-a---- .gitattributes
-a---- .gitignore
-a---- docker-compose.dcproj
-a---- docker-compose.override.yml
-a---- docker-compose.yml
-a---- myProc.sln
When you run the build command
docker build .
The . in that command indicates the "build context" that gets sent to the (possibly remote) docker engine. All of the COPY and ADD commands must be from inside this directory (or from a previous stage with multi stage builds). You can also exclude files from this context using the .dockerignore file. The tmp directory is a uniquely generated internal directory of docker's consisting of this build context.
To fix your issue, you need to make sure ProcessFiles/ProcessFiles.csproj exists in the directory where you run your build from, and that you didn't exclude it from the context with the .dockerignore file.
Edit: based on your comments, change your copy command to:
COPY ProcessFiles.csproj ProcessFiles/
Seems like VS is generating a bad dockerfile.
The answer provided BMitch is correct in my case as well, however it ends up in another error.
Short story:
Removed the project's folder from the source path in the first COPY statement
Added the project's folder to the dest path in the COPY . . statement
Long story:
https://developercommunity.visualstudio.com/content/problem/459905/docker-build-failes-with-dockerfile-created-by-vs.html

Docker "/bin/bash" could not be invoked when mounting an NFS file with -v on openstack

I'm running an Ubuntu 14.04 instance that has docker installed on openstack. I'm trying to mount a volume into a docker container. I'm doing this with
docker run -t -i -v /mnt/data/dir:/mnt/test ubuntu
Where /mnt/data/dir is an NFS shared directory. Doing this gets me:
docker:
Error response from daemon: Container command '/bin/bash' could not be invoked..
However, using a local directory instead of a mounted directory works exactly as expected.
I understand that docker doesn't natively support an NFS mounted file system, however the errors I googled are usually not of the form that I've mentioned above.
Any clue on how to proceed
Edit: I forgot to mention that its not just limited to /bin/bash could not be invoked. I tried running a tomcat server and that gave me the exact same error.

Why I can't see my files inside a docker container?

I'm a Docker newbie and I'm trying to setup my first project.
To test how to play with it, I just cloned one ready-to-go project and I setup it (Project repo).
As the guide claims if I access a specific url, I reach the homepage. To be more specific a symfony start page.
Moreover with this command
docker run -i -t testdocker_application /bin/bash
I'm able to login to the container.
My problem is if I try to go to the application folder through bash, the folder that I shared with my host is empty.
I tried with another project, but the result is the same.
Where I'm wrong?
Here some infos about my env:
Ubuntu 12.04
Docker version 1.8.3, build f4bf5c7
Config:
application:
build: code
volumes:
- ./symfony:/var/www/symfony
- ./logs/symfony:/var/www/symfony/app/logs
tty: true
Looks like you have a docker-compose.yml file but are running the image with docker. You don't actually need docker-compose to start a single container. If you just want to start the container your command should look like this:
docker run -ti -v $(pwd)/symfony:/var/www/symfony -v $(pwd)/logs/symfony:/var/www/symfony/app/logs testdocker_application /bin/bash
To use your docker-compose.yml start your container with docker-compose up. You would also need to add the following to drop into a shell.
stdin_open: true
command: /bin/bash

Docker permissions development environment using a host mounted volume

I'm using docker-compose to set up a portable development environment for a bunch of symfony2 applications (though nothing I want to do is specific to symfony). I've decided to have the source files on the local machine exposed as a data volume with all the other dependencies in docker. This way developers can edit on the local file-system.
Everything works great, except that after running the app my cache and log files and the files created by composer in the /vendor directory are now owned by root.
I've read about this problem and some possible approaches here:
Changing permissions of added file to a Docker volume
But I can't quite quite tease out what changes I have to make in my docker-compose.yml file so that when my symphony container starts with docker-compose up any files that are created have the permissions of the user on the host machine.
I'm posting the file for reference, worker is where php, etc. live:
source:
image: symfony/worker-dev
volumes:
- $PWD:/var/www/app
mongodb:
image: mongo:2.4
ports:
- "27017:27017"
volumes_from:
- source
worker:
image: symfony/worker-dev
ports:
- "80:80"
- mongodb
volumes_from:
- source
volumes:
- "tmp/:/var/log/nginx"
One of the solutions is to execure the commands inside your container. I've tried multiple workarounds for the same issue I faced in the past. I find executing the command inside the container the most user-friendly.
Example command: docker-compose run CONTAINER_NAME php bin/console cache:clear. You may use make, ant or any modern tool to keep the commands short.
Example with Makefile:
all: | build run test
build: | docker-compose-build
run: | composer-install clear-cache
############## docker compose
docker-compose-build:
docker-compose build
############## composer
composer-install:
docker-compose run app composer install
composer-update:
docker-compose run app composer update
############## cache
clear-cache:
docker-compose run app php bin/console cache:clear
docker-set-permissions:
docker-compose run app chown -R www-data:www-data var/logs
docker-compose run app chown -R www-data:www-data var/cache
############## test
test:
docker-compose run app php bin/phpunit
Alternatively, you may introduce a .env file which contains a environment variables and then user one of the variables to run usermod command in the Docker container.

Resources