Individual assignment 3
Practice building Docker images
Instructions
The purpose of this assignment is to ensure that everyone gains hands-on practice on creating Docker images from Dockerfile
s.
Submission instructions
In the text box provided for this assignment on Canvas, you must submit:
- A link to the GitHub.com repository that you create for this assignment.
- You should name your GitHub.com repository
dsci310-ia3-<USERNAME>-docker
. - You need to create this assignment in the course organization: https://github.com/DSCI-310-2025
- You should name your GitHub.com repository
- A the link to your Docker image on DockerHub. You should name your DockerHub repository
dsci310-ia3-<USERNAME>-docker
.
Make sure your repository is under the DSCI-310-2025
organization. You can do a “repository transfer” if you need to, but your submission needs to be in the correct org.
Exercise instructions
- Create a public repository on GitHub.com repo under your personal username called
dsci310-ia3-<USERNAME>-docker
- You can choose a pre-made
.gitignore
or manually create one yourself
- You can choose a pre-made
- Add a
Dockerfile
to it. This Dockerfile should be based off of therocker/rstudio:4.4.2
Docker image - Add at least one new R package to the Dockerfile using (ensure that you pin the version of the package you add).
- There are 2 ways of doing this. There are different benefits to each of the methods depicted. You only need to do one of them for the assignment.
- One way is to turn your
dsci310-ia3-<USERNAME>-docker
into a local RStudio project then do the following steps:- Open the RStudio project locally
- Initialize the project with renv
- Use
{renv}
to install a package (e.g.,cowsay
) and then make sure you create a script that loads/uses the{cowsay}
package. - In your
Dockerfile
COPY
all your renv files into the container - Use the outputs from
renv
to help you specify which functions to use to install the libraries
- Hint: you might need to toggle the
USER
in theDockerfile
betweenrstudio
androot
to get everything working.
- Another way is to
RUN
commands directly in theDockerfile
to install packages- Hint: You cannot use
install.packages()
because you can’t pin a version number. - Hint: You can run R code directly from the command line. For example,
Rscript -e "print('something to say...')"
. Make sure to change the double quotes""
to single quotes''
in the R code. - Hint: You will need to first install the
{remotes}
package, and then use theremotes::install_version()
function
- Hint: You cannot use
- Build your
Dockerfile
and test it locally. - Add a GitHub Actions workflow to automatically build the image, push it to DockerHub, and version the image and GitHub repo when changes are pushed to the Dockerfile
- Use the “Docker image” workflow
- You can also start off with an empty file and paste in a workflow by clicking “Skip this and setup a workflow yourself”.
- You will need to add your DockerHub username and password (naming them
DOCKER_USERNAME
andDOCKER_PASSWORD
, respectively) as GitHub secrets to this repository for this to work. - Here are some resources to help you create your own Github Action Workflow:
- Github Actions Docker reference: https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
- Use the “Docker image” workflow
(As Needed): Make sure you make at least one change to the Dockerfile
once the GitHub Actions have been setup so that you get the image automatically built and pushed to DockerHub at least once. - You can also add a workflow_dispatch:
trigger and manually trigger a workflow
- Note: If you are making an
renv.lock
file and you notice it’s not updating withrenv::snapshot()
, take a look at this FAQ
Rubric
This assignment will be graded for completion as follows:
- A Docker image named
dockerfile-practice
and tagged with a version exists under the student’s username on DockerHub. - The Dockerfile used to create the Docker image lives in a GitHub repository named
dsci310-ia3-<USERNAME>-docker
under the DSCI-310 org. - There is evidence that a GitHub Actions workflow can successfully build a Docker image from the Dockerfile in the GitHub repository, and publish it to DockerHub.
The Docker image version tag is in sync with the GitHub repository release tag.(Not needed – Free Point)- At least one new R package was added to the Dockerfile and the version of that package was pinned.
Grade | Description |
---|---|
100% | 5/5 of the criteria listed above were met. |
75% | 4/5 of the criteria listed above were met. |
50% | 3/5 of the criteria listed above were met. |
25% | 2/5 of the criteria listed above were met. |
0% | Only 1/5 of the criteria listed above were met or the assignment was not attempted. |
50% | Maximum amount of points if created in the wrong organization |
Additional points taken off:
- -2% for checking in files that are not supposed to be in the repository (temporary system files, thumbnail files, IDE user files, etc)