50
loading...
This website collects cookies to deliver better user experience
If any of your R packages dependend on system libraries which aren't > included by > Heroku, such as > libgmp
, libgomp
, libgdal
, libgeos
and libgsl
, you should use > the Heroku container > stack > together with > heroku-docker-r > instead. – Maintainers of > heroku-buildpack-r
git
to be installed locally to be able to make changes to the git repository we are going to create.heroku --version
to test if the CLI is ready to be used. Then type heroku login
which will prompt you to type in credentials. Next time the CLI will log you in automatically.heroku-hello
and inside a Dockerfile
:mkdir heroku-hello
cd heroku-hello
touch Dockerfile
Dockerfile
:FROM registry.gitlab.com/analythium/shinyproxy-hello/hello
ENV PORT=3838
CMD ["R", "-e", "shiny::runApp('/home/app', host = '0.0.0.0', port=as.numeric(Sys.getenv('PORT')))"]
CMD
part is different from previous Dockerfiles that we used. The port number is passed as an environment variable by the Heroku container runtime. Therefore the runApp()
command needs to pick up the port number using Sys.getenv('PORT')
. The reason we add ENV PORT=3838
is to help with local testing.$PORT
variable
instead of hard coding and exposing a specific port.docker build -t heroku-hello .
docker run -p 3838:3838 heroku-hello
127.0.0.1:3838
to see the familiar purple histogram with the sample size slider.heroku.yml
(touch heroku.yml
) file in your application's root directory. The following example heroku.yml
specifies the Dockerfile to be used to build the image for the app’s web process:build:
docker:
web: Dockerfile
# Initialize the local directory as a Git repository
git init -b main
# Add the files and stage them for commit
git add .
# Commit tracked changes and sign-off the message
git commit -s -m "First commit"
heroku create --stack=container
Creating app... done, ⬢ morning-plateau-34336, stack is container
https://morning-plateau-34336.herokuapp.com/ | https://git.heroku.com/morning-plateau-34336.git
heroku stack:set container
.main
with your branch name if it is different:git push heroku main
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 1.09 KiB | 1.09 MiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: === Fetching app code
remote:
remote: === Building web (Dockerfile)
remote: Sending build context to Docker daemon 3.072kB
remote: Step 1/3 : FROM registry.gitlab.com/analythium/shinyproxy-hello/hello
remote: latest: Pulling from analythium/shinyproxy-hello/hello
remote: 4363cc522034: Pulling fs layer
...
remote: Successfully built 8b891983b438
remote: Successfully tagged 6dc2e345582f143cd104cf98fec788c65e9a72a6:latest
remote:
remote: === Pushing web (Dockerfile)
remote: Tagged image "6dc2e345582f143cd104cf98fec788c65e9a72a6" as "registry.heroku.com/morning-plateau-34336/web"
remote: Using default tag: latest
remote: The push refers to repository [registry.heroku.com/morning-plateau-34336/web]
remote: cec4817fd20b: Preparing
...
remote: Verifying deploy... done.
To https://git.heroku.com/morning-plateau-34336.git
* [new branch] main -> main
heroku open
command: