flame

路漫漫其修远兮 吾将上下而求索

0%

c开发环境-基于vim和docker配置

前言

基于vimdocker的c开发环境

docker

Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update

RUN apt-get install -y tzdata
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN dpkg-reconfigure --frontend noninteractive tzdata

RUN apt-get install -y ssh
RUN apt-get install -y build-essential
RUN apt-get install -y gcc
RUN apt-get install -y g++
RUN apt-get install -y gdb
RUN apt-get install -y clang
RUN apt-get install -y cmake
RUN apt-get install -y automake
RUN apt-get install -y pkg-config
RUN apt-get install -y rsync
RUN apt-get install -y tar
RUN apt-get install -y python
RUN apt-get install -y vim
RUN apt-get install -y sudo
RUN apt-get install -y ctags
RUN apt-get install -y git
RUN apt-get install -y python3-dev

RUN apt-get clean autoclean

RUN yes root | passwd root
RUN mkdir /run/sshd

RUN mkdir -p /root/.vim/bundle/Vundle.vim
ADD ./Vundle.vim /root/.vim/bundle/Vundle.vim
ADD ./vim.rc /root/.vimrc
ADD ./vim_plugins_install.sh /root/vim_plugins_install.sh
RUN ["chmod", "+x", "/root/vim_plugins_install.sh"]
ADD ./ycm_extra_conf.py /root/ycm_extra_conf.py

RUN ( \
echo 'PermitRootLogin yes'; \
echo 'PasswordAuthentication yes'; \
echo 'Subsystem sftp /usr/lib/openssh/sftp-server'; \
) > /etc/ssh/sshd_config_test_clion

RUN /root/vim_plugins_install.sh
CMD ["/usr/sbin/sshd", "-D", "-e", "-f", "/etc/ssh/sshd_config_test_clion"]


镜像

1
docker build -t c-vim-env/c_vim_env:0.1 -f Dockerfile .

启动

1
docker run -it -d --cap-add sys_ptrace -p127.0.0.1:2223:22 --name c-vim --hostname c-vim-machine c-vim-env/c_vim_env:0.1

登录

1
docker exec -it c-vim /bin/bash

样例

1
2
3
4
cd /root/
git clone https://github.com/huangz1990/redis-3.0-annotated.git
cd redis-3.0-annotated
cp ../ycm_extra_conf.py .ycm_extra_conf.py

样例

项目

项目-github

reference

YouCompleteMe
use_vim_as_ide
http://www.skywind.me/blog/archives/2084
http://vim.zhangjikai.com/%E6%8F%92%E4%BB%B6/vundle.html

vim配置