Docker搭建vue3开发环境

环境基本说明:
基于node16.3官方镜像, vue-cli版本为4.5. 可以根据自己的需求进行调整.

创建Dockerfile, 内容如下

FROM node:16.3

# system local config
RUN true \
    # debian china mirrors
    && sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list \
    && sed -i 's/security.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list \
    # timezone to china
    && ln -sf /usr/share/zoneinfo/PRC /etc/localtime 

RUN apt-get update \
    && apt-get install -y \
    # node-sass 等编译依赖
    make gcc g++ python \
    # 命令行工具
    zsh curl wget vim git


RUN true \
    && npm config set registry https://registry.npm.taobao.org \
    && npm install webpack -g \  
    && npm install -g @vue/cli@4.5

RUN mkdir /home/code

WORKDIR /home/code

# 给这个目录执行权限,x是执行权限
RUN chmod +x /home/code

VOLUME /home/code

EXPOSE 3000

CMD ["/bin/bash"]

执行build命令

docker build -t vue3 ./

稍等几分钟, 就会得到名称是vue3的镜像

Tags:

Add a Comment

您的电子邮箱地址不会被公开。