Skip to content

Conversation

@jcrodriguez1989
Copy link
Contributor

Resolves #3
Please let me know if further changes should be addressed 🚀

@jcrodriguez1989
Copy link
Contributor Author

Example:

library(dockerfiler)
# Create a dockerfile template
my_dock <- Dockerfile$new()
my_dock$MAINTAINER("Colin FAY", "[email protected]")
my_dock$COMMENT("Install required R package.")
my_dock$RUN(r(install.packages("attempt", repo = "http://cran.irsn.fr/")))
my_dock$COMMENT("Copy Plumber API and main script to container.")
my_dock$RUN("mkdir /usr/scripts")
my_dock$RUN("cd /usr/scripts")
my_dock$COPY("plumberfile.R", "/usr/scripts/plumber.R")
my_dock$COPY("torun.R", "/usr/scripts/torun.R")
my_dock$COMMENT("Expose the API port and run the main script when the container starts.")
my_dock$EXPOSE(8000)
my_dock$CMD("Rscript /usr/scripts/torun.R ")
my_dock
FROM rocker/r-base
MAINTAINER Colin FAY <[email protected]>
# Install required R package.
RUN R -e 'install.packages("attempt", repo = "http://cran.irsn.fr/")'
# Copy Plumber API and main script to container.
RUN mkdir /usr/scripts
RUN cd /usr/scripts
COPY plumberfile.R /usr/scripts/plumber.R
COPY torun.R /usr/scripts/torun.R
# Expose the API port and run the main script when the container starts.
EXPOSE 8000
CMD Rscript /usr/scripts/torun.R

@jcrodriguez1989
Copy link
Contributor Author

jcrodriguez1989 commented Oct 1, 2024

FYI, this happens with most my_dock$... commands.
Just one question, with this PR we are having the following unexpected behavior.

> library(dockerfiler)
> my_dock <- Dockerfile$new()
> my_dock$COMMENT("Comment 1 \nComment 2")
> my_dock
FROM rocker/r-base
# Comment 1 
Comment 2

How should we handle it?

  1. Doing nothing, the user should be aware of the comment input.
  2. Warning, but still returning the wrong Dockerfile.
  3. Remove the newlines, and put all of the comments in the same comment line (# Comment 1 Comment 2).
  4. Break the newlines into multiple comment lines.

@VincentGuyader
Copy link
Member

HI,

I vote for option 4
I know this PR is from a while back, but I'd like to include it in the next release :)

1 similar comment
@VincentGuyader
Copy link
Member

HI,

I vote for option 4
I know this PR is from a while back, but I'd like to include it in the next release :)

@VincentGuyader VincentGuyader self-assigned this Apr 11, 2025
@jcrodriguez1989
Copy link
Contributor Author

Hi @VincentGuyader , fixed for new lines in comments.
Let me know your thoughts.
Best,

@VincentGuyader VincentGuyader merged commit 77450cc into ThinkR-open:master May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create a dock$COMMENT() to add a comment in the Dockerfile

2 participants