Skip to content

Commit

Permalink
chore: dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
BroKun authored and sunshinesmilelk committed Sep 4, 2024
1 parent 8a5e38a commit c55772d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/heroku.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ jobs:
steps:
# Check-out your repository.
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3


### ⬇ IMPORTANT PART ⬇ ###
### ⬇ IMPORTANT PART ⬇ ###

- name: Build, Push and Release a Libro Lab Docker container to Heroku. # Your custom step name
uses: gonuit/[email protected] # GitHub action name (leave it as it is).
Expand All @@ -27,11 +26,11 @@ jobs:
# If you don't want to use repository secrets (which is recommended) you can do:
# email: [email protected]
email: ${{ secrets.HEROKU_EMAIL }}

# Heroku API key associated with provided user's email.
# Api Key is available under your Heroku account settings.
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}

# Name of the heroku application to which the build is to be sent.
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}

Expand All @@ -46,14 +45,11 @@ jobs:

# (Optional, default: "")
# Additional options of docker build command.
docker_options: "--no-cache"
docker_options: '--no-cache'

# (Optional, default: "web")
# Select the process type for which you want the docker container to be uploaded.
# By default, this argument is set to "web".
# For more information look at https://devcenter.heroku.com/articles/process-model
process_type: web



### ⬆ IMPORTANT PART ⬆ ###
### ⬆ IMPORTANT PART ⬆ ###
29 changes: 26 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
# 使用 python 3.11 作为基础镜像
FROM python:3.11-slim-bookworm

# 创建 ADMIN 用户并设置其为非特权用户
RUN useradd -m admin

# 安装 libro 包
RUN pip install libro
RUN mkdir -p ~/.jupyter
COPY docker/jupyter_server_config.py ~/.jupyter/jupyter_server_config.py

CMD ["libro", '--port', '8889',"--allow-root"]
# 创建 Jupyter 配置目录和工作区目录
RUN mkdir -p /home/admin/.jupyter /home/admin/workspace

# 复制 Jupyter 配置文件
COPY docker/jupyter_server_config.py /home/admin/.jupyter/jupyter_server_config.py

# 复制启动脚本到镜像中
COPY docker/start.sh /home/admin/start.sh

# 赋予启动脚本执行权限
RUN chmod +x /home/admin/start.sh

# 更改文件和目录的所有权为 admin 用户
RUN chown -R admin:admin /home/admin

# 切换到 admin 用户
USER admin

# 设置工作目录为 admin 用户的主目录
WORKDIR /home/admin

# 使用 ENTRYPOINT 来设置启动脚本
ENTRYPOINT ["/home/admin/start.sh"]
10 changes: 10 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# 检查 PORT 环境变量是否设置
if [ -z "$PORT" ]; then
echo "PORT 环境变量未设置"
exit 1
fi

# 启动 libro,并将 PORT 环境变量传递给它
exec libro --port="$PORT"

0 comments on commit c55772d

Please sign in to comment.