吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1234|回复: 0
收起左侧

[其他转载] 自定义Dockerfile:Debian-NVM

[复制链接]
lyly125 发表于 2021-12-23 10:01
本帖最后由 lyly125 于 2021-12-23 10:03 编辑

来吾爱好多年了,但是一直没有发过帖子,这是第一次发贴,如有错误的地方还请版主大大告知,立马改正!最近在学习和研究Docker,打算自定义一套自己的node相关镜像,采用的是Docker官方的 debian:bullseye 版本,安装NVM管理工具。由于环境问题,装Debian的官方源替换成清华源,用手动方式安装NVM:需要在Build之前先在Github下载想要安装的NVM版本源码,放在Dockerfile文件所在目录(必须!)
下面是我修改的Dockerfile代码,如果各位大大有疑问或者建议可以提出,本人还只是个菜鸟,希望和各位大大交流学习!

FROM debian:bullseye

################################Custom##########################################

# set timezone
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# install apt-transport-https ca-certificates
RUN  apt-get update \
  && apt-get install -y apt-transport-https ca-certificates

# https://mirrors.tuna.tsinghua.edu.cn/help/debian/
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
  echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free" >> /etc/apt/sources.list  && \
  echo "# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free" >> /etc/apt/sources.list  && \
  echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free" >> /etc/apt/sources.list  && \
  echo "# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free" >> /etc/apt/sources.list  && \
  echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free" >> /etc/apt/sources.list  && \
  echo "# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free" >> /etc/apt/sources.list  && \
  echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list  && \
  echo "# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list

# install the git and other app we need
RUN apt-get update \
  && apt-get install -y git vim wget \
  && rm -rf /var/lib/apt/lists/*

# nvm config for ~/.bashrc, ~/.profile, or ~/.zshrc file
RUN { \
  echo 'export NVM_DIR="$HOME/.nvm"'; \
  echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm'; \
  echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion'; \
  } > /root/.bashrc

# copy nvm folder from host to container
COPY nvm/ root/.nvm/

# install node 12
RUN /bin/bash -c "source /root/.bashrc;nvm install 12"

# install lts, sass, sass-convert
# RUN /bin/bash -c "source /root/.bashrc"
# RUN /bin/bash -c "source /root/.bashrc;nvm install --lts"
# RUN /bin/bash -c "source /root/.bashrc;npm install -g sass"
# RUN /bin/bash -c "source /root/.bashrc;npm install apidoc -g"
# RUN /bin/bash -c "source /root/.bashrc;npm install -g sass-convert"

EXPOSE 80
EXPOSE 443

WORKDIR "/var/www/html"

Github地址

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 11:22

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表