Skip to content
Snippets Groups Projects
Commit 10ed28bf authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

Merge branch 'main-cleanup' into 'main'

cleanup up main to have a common base to R and python

See merge request hub/rshiny-k8s-example!2
parents 9bff5e25 ea5c11a0
No related branches found
No related tags found
1 merge request!2cleanup up main to have a common base to R and python
Pipeline #106352 failed
......@@ -6,6 +6,8 @@ services:
build:
except:
- main
stage: build
needs: []
before_script:
......@@ -29,6 +31,8 @@ build:
.deploy:
except:
- main
stage: deploy
needs:
- "build"
......
# FROM registry-gitlab.pasteur.fr/hub/rshiny-k8s:4.2.3--1.5.21.1006
# FROM registry-gitlab.pasteur.fr/hub/rshiny-k8s:1.5.21.1006
# FROM registry-gitlab.pasteur.fr/hub/rshiny-k8s:4.2.3
FROM registry-gitlab.pasteur.fr/hub/rshiny-k8s:latest
# install additional dependencies, comment the block if you don't have one
RUN apt-get update \
&& apt-get install -y \
wget \
&& rm -rf /var/lib/apt/lists/*
# Copy your dependencies, destination filename must be "packages_to_install.csv"
COPY ./my_packages_to_install.csv /opt/scripts/packages_to_install.csv
# Install R packages
RUN Rscript /opt/scripts/install_r_packages.R
# grant shiny to created bookmark state directory in this directory
RUN chown shiny:shiny /var/lib/shiny-server
# Copy you shiny app
COPY ./example_proj /srv/shiny-server
# Name : app.R
# Folder : ~/rshiny-k8s/example_proj
# Date : 05/04/23
# Aim : Simple example of app developped in RShiny.
# Authors : From Shiny Examples - Modify by Elodie C. et Bryan B.
# Load packages -------------------------------------------------------------------
library(shiny)
library(shinythemes)
library(ggplot2)
### Try to fix error "unable to open connection to X11"
options(bitmapType='cairo')
# Show installed and loaded packages
sessionInfo()
# UI part -------------------------------------------------------------------------
# Define UI for app that draws a histogram ----
ui <- fluidPage(
# App title ----
titlePanel("Hello Shiny in docker image!"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
# Input: Slider for the number of bins ----
sliderInput(inputId = "bins",
label = "Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Main panel for displaying outputs ----
mainPanel(
# Output: Histogram ----
plotOutput(outputId = "distPlot"),
# Output: SessionInfo fecth from server
htmlOutput("mySessionInfo")
)
)
)
# Server part -------------------------------------------------------------------------
# Define server logic required to draw a histogram ----
server <- function(input, output) {
# Histogram of the Old Faithful Geyser Data ----
# with requested number of bins
# This expression that generates a histogram is wrapped in a call
# to renderPlot to indicate that:
#
# 1. It is "reactive" and therefore should be automatically
# re-executed when inputs (input$bins) change
# 2. Its output type is a plot
output$distPlot <- renderPlot({
x <- faithful$waiting
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = "#75AADB", border = "white",
xlab = "Waiting time to next eruption (in mins)",
main = "Histogram of waiting times")
})
output$mySessionInfo <- renderPrint({
capture.output(sessionInfo())
capture.output(capabilities())
})
}
# Run Shiny app ----------------------------------------------------------------------
shinyApp(ui = ui, server = server)
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: rshiny-deployment
labels:
app: rshiny-app
spec:
selector:
matchLabels:
app: rshiny-app
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: rshiny-app
spec:
containers:
- name: rshiny-pod
image: registry-gitlab.pasteur.fr/hub/rshiny-k8s-example/main/example:latest
securityContext:
runAsGroup: 999
runAsUser: 999
ports:
- name: http
containerPort: 3838
protocol: TCP
resources:
requests:
memory: "256Mi"
cpu: "500m"
limits:
memory: "512Mi"
cpu: "500m"
imagePullSecrets:
- name: registry-gitlab
---
\ No newline at end of file
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: rkubshiny-hpa
labels:
app: rshiny-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: rshiny-deployment
minReplicas: 1
maxReplicas: 4
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 80
- type: Resource
resource:
name: memory
targetAverageUtilization: 80
\ No newline at end of file
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/affinity: cookie
nginx.ingress.kubernetes.io/proxy-body-size: 256m
name: rshiny-ingress
spec:
ingressClassName: internal
rules:
- host: rshiny-example.dev.pasteur.cloud
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: rshiny-srv
port:
number: 8080
---
\ No newline at end of file
---
apiVersion: v1
kind: Service
metadata:
name: rshiny-srv
spec:
type: ClusterIP
ports:
- name: http
port: 8080
targetPort: 3838
selector:
app: rshiny-app
---
\ No newline at end of file
Package_name;Comments
shinythemes;cran package
ggplot2;cran package
limma;bioconductor package
tidyverse/tibble; github package
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment