Skip to content

Commit

Permalink
Add minimal alpine image
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Solymos <psolymos@gmail.com>
  • Loading branch information
psolymos committed Jul 9, 2024
1 parent 2b8f745 commit 6cc2ef8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
34 changes: 34 additions & 0 deletions r-shiny/Dockerfile.minimal
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Define the parent image
FROM rhub/r-minimal:4.4.1

# Install dependencies
# -d install C and C++ compilers, temporarily
# -t install Alpine packages, temporarily
# -a install Alpine packages and keep them
RUN installr -d \
-t "zlib-dev cairo-dev" \
-a "cairo font-liberation" \
Cairo \
shiny

# Add non-root user and group
RUN addgroup --system app && \
adduser --system --ingroup app app

# Set working directory to home of the non-root user
WORKDIR /home/app

# Copy Shiny app files
COPY app .

# Set owner for the home folder
RUN chown app:app -R /home/app

# Set user to non-root
USER app

# Expose port
EXPOSE 3838

# Set command to execute at runtime
CMD ["R", "-e", "shiny::runApp(host='0.0.0.0', port=3838)"]
23 changes: 22 additions & 1 deletion r-shiny/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ docker pull ghcr.io/h10y/faithful/r-shiny:latest
docker run -p 8080:3838 ghcr.io/h10y/faithful/r-shiny:latest
```

Containerized version:
Containerized version using `rocker/r2u`
[image size: 909MB, build time: 16 sec]

```bash
# Change directory
Expand All @@ -38,3 +39,23 @@ docker build -t $TAG .
# Run image, visit http://localhost:8080
docker run --rm -p 8080:3838 $TAG
```

Using `rhub/r-minimal` from <https://github.com/r-hub/r-minimal/>.
[Image size: 113MB, build time: 5 min]

```bash
# Change directory
cd r-shiny

# If on MacOS X, set this
export DOCKER_DEFAULT_PLATFORM=linux/amd64

# Specify tag
export TAG=faithful/r-shiny:minimal

# Build image
docker build -t $TAG -f Dockerfile.minimal .

# Run image, visit http://localhost:8080
docker run --rm -p 8080:3838 $TAG
```

0 comments on commit 6cc2ef8

Please sign in to comment.