Skip to content

Commit

Permalink
Apply changes to docker example
Browse files Browse the repository at this point in the history
  • Loading branch information
soapy1 committed Nov 27, 2024
1 parent e944049 commit 35e82c2
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docusaurus-docs/conda-store/how-tos/install-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ docker compose up --build

On your web browser, visit: [https://conda-store.localhost/conda-store](https://conda-store.localhost/conda-store).

By default, you can log in with any username and use the password `password`, since we are using `DummyAuthenticator`/`
This example uses the JupyterHub OAuth Authenticator. You can log in with the test admin user `admin`, with password `test`.
6 changes: 4 additions & 2 deletions examples/docker/assets/conda_store_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# conda-store settings
# ==================================
c.CondaStore.storage_class = S3Storage
c.CondaStore.store_directory = "/opt/conda-store/conda-store"
c.CondaStore.store_directory = "/var/lib/conda-store/"
c.CondaStore.environment_directory = "/opt/conda-store/envs/{namespace}-{name}"
# Also edit `conda-store-server/alembic.ini` accordingly for key sqlalchemy.url
c.CondaStore.database_url = (
"postgresql+psycopg2://postgres:password@postgres/conda-store"
Expand Down Expand Up @@ -51,11 +52,12 @@
# auth settings
# ==================================
c.CondaStoreServer.authentication_class = JupyterHubOAuthAuthentication
c.JupyterHubOAuthAuthentication.jupyterhub_url = "https://conda-store.localhost"
c.JupyterHubOAuthAuthentication.jupyterhub_url = "http://conda-store.localhost"
c.JupyterHubOAuthAuthentication.client_id = "service-this-is-a-jupyterhub-client"
c.JupyterHubOAuthAuthentication.client_secret = "this-is-a-jupyterhub-secret"
c.JupyterHubOAuthAuthentication.oauth_callback_url = "/conda-store/oauth_callback/"
c.JupyterHubOAuthAuthentication.tls_verify = False
c.JupyterHubOAuthAuthentication.access_scope = "conda-store-user"

# ==================================
# worker settings
Expand Down
17 changes: 16 additions & 1 deletion examples/docker/assets/jupyterhub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,24 @@ def preexec():
"name": "conda-store",
"oauth_client_id": "service-this-is-a-jupyterhub-client",
"admin": True,
"url": "https://conda-store.localhost/conda-store/",
"url": "http://conda-store.localhost/conda-store/",
"api_token": "this-is-a-jupyterhub-secret",
"oauth_redirect_uri": "/conda-store/oauth_callback/",
"oauth_no_confirm": True, # allows no authorize yes/no button
"oauth_client_allowed_scopes": [
"self", "inherit", "access:services",
]
}
]

c.JupyterHub.load_roles = [
{
"name": "conda-store-user",
"scopes": [
"self", 'access:services!service=conda-store',
],
"groups": ["conda-store-user"],
}
]

c.Authenticator.admin_users = {'admin'}
32 changes: 6 additions & 26 deletions examples/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

volumes:
conda_store_data:
redis:
Expand All @@ -12,19 +10,15 @@ services:
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.exposedbydefault=true"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.minio.address=:9080"
- "--entrypoints.websecure.http.tls=true"
- "--entrypoints.minio.http.tls=true"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
- "--entrypoints.web.http.redirections.entrypoint.permanent=true"
ports:
- "80:80"
- "443:443"
- "8080:8080"
- "9080:9080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
Expand All @@ -42,7 +36,6 @@ services:
image: quansight/conda-store-server
user: 1000:1000
volumes:
- conda_store_data:/opt/conda-store/
- ./assets/conda_store_config.py:/etc/conda-store/conda_store_config.py:ro
depends_on:
initializer:
Expand All @@ -60,7 +53,6 @@ services:
labels:
- "traefik.enable=true"
- "traefik.http.routers.conda-store.rule=Host(`conda-store.localhost`) && (PathPrefix(`/conda-store`) || PathPrefix(`/v2`))"
- "traefik.http.routers.conda-store.entrypoints=websecure"
- "traefik.port=8080"
depends_on:
postgres:
Expand All @@ -82,11 +74,14 @@ services:
- "8080:8080"

jupyterhub:
image: quansight/conda-store
build:
context: dockerfiles
dockerfile: jupyterhub.Dockerfile
args:
python_version: 3.11
labels:
- "traefik.enable=true"
- "traefik.http.routers.jupyterhub.rule=Host(`conda-store.localhost`) && (Path(`/`) || PathPrefix(`/hub`) || PathPrefix(`/user`))"
- "traefik.http.routers.jupyterhub.entrypoints=websecure"
- "traefik.port=8000"
user: 1000:1000
healthcheck:
Expand Down Expand Up @@ -142,21 +137,6 @@ services:
POSTGRES_PASSWORD: password
POSTGRES_DB: conda-store

mysql:
image: mysql:8.0
ports:
- 3306:3306
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
environment:
MYSQL_ROOT_PASSWORD: hbgY8bkoWPMM7EjtcD6wrlVX
MYSQL_USER: admin
MYSQL_PASSWORD: password
MYSQL_DATABASE: conda-store

redis:
image: bitnami/redis
healthcheck:
Expand Down
41 changes: 41 additions & 0 deletions examples/docker/dockerfiles/jupyterhub.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) conda-store development team. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

FROM condaforge/miniforge3:24.9.2-0 AS base

LABEL org.opencontainers.image.authors="conda-store development team"

# must be passed at build environment (should use .python-version-default)
ARG python_version
ARG conda_env_name="conda-store"
ARG user_no=1000

# ensure we are using the conda environment
ENV PATH=/opt/conda/condabin:/opt/conda/envs/conda-store/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}

RUN apt-get update && \
apt-get install -yq --no-install-recommends curl && \
apt-get clean && \
rm -rf /var/cache/apt/* &&\
rm -rf /var/lib/apt/lists/* &&\
rm -rf /tmp/* &&\
groupadd -g ${user_no} conda-store &&\
useradd -M -r -s /usr/sbin/nologin -u ${user_no} -g ${user_no} conda-store && \
mkdir -p /opt/jupyterhub && \
chown -R conda-store:conda-store /opt/jupyterhub

RUN mamba create --name ${conda_env_name} \
python=${python_version} nb_conda_kernels nodejs=18 yarn constructor conda-store \
--channel conda-forge -y && \
mamba clean --all -y && \
conda clean --force-pkgs-dirs

RUN python -m pip install jupyter-launcher-shortcuts jupyterlab-conda-store jupyterlab\>=4.0.0 jupyterhub\>3.1.1

RUN npm install -g configurable-http-proxy

WORKDIR /opt/conda-store

USER conda-store
WORKDIR /opt/jupyterhub

0 comments on commit 35e82c2

Please sign in to comment.