Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
docs(dockerfile): 更新code安装和使用
Browse files Browse the repository at this point in the history
  • Loading branch information
zjZSTU committed Oct 8, 2019
1 parent 7a5b641 commit e639dbe
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
9 changes: 6 additions & 3 deletions dockerfiles/code/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@

FROM zjzstu/ubuntu:latest
FROM zjzstu/ubuntu:18.04
LABEL maintainer "zhujian <zjzstu@github.com>"

ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8

WORKDIR /app
COPY code*.deb ./
RUN set -eux && \
# 安装依赖和额外工具
apt-get update && \
apt-get install -y libnotify4 libnss3 gnupg libxkbfile1 libsecret-1-0 libgtk-3-0 libxss1 libx11-xcb1 libasound2 libcanberra-gtk-module libglib2.0-0 dbus wget gosu && \
apt-get install -y --fix-missing apt apt-utils libnotify4 libnss3 gnupg libxkbfile1 libgconf-2-4 libglu1-mesa libsecret-1-0 libgtk-3-0 libxss1 libx11-xcb1 libasound2 libglib2.0-0 libgl1-mesa-glx libva-glx2 dbus wget gosu python3-pip curl libcanberra-gtk3-0 && \
# verify that the binary works
gosu nobody true && \
# 下载安装包
# wget https://vscode.cdn.azure.cn/stable/b37e54c98e1a74ba89e03073e5a3761284e3ffb0/code_1.38.1-1568209190_amd64.deb && \
# 新建用户user,并修改安装包属主/属组
useradd -s /bin/bash -m user && \
chown user:user *.deb && \
chmod a+x *.deb && \
dpkg -i code_1.38.1-1568209190_amd64.deb && \
# 删除
rm code*.deb && \
apt-get autoremove -y --purge && apt-get autoclean -y && apt-get clean -y && \
apt-get autoclean -y && apt-get clean -y && \
find /var/lib/apt/lists -type f -delete && \
find /var/cache -type f -delete && \
find /var/log -type f -delete && \
Expand Down
34 changes: 33 additions & 1 deletion dockerfiles/code/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
能安装`code`,存在网络连接问题

参考:

[sshcode](https://github.com/cdr/sshcode)

[code-server](https://github.com/cdr/code-server)

[WSL下使用VcXsrv启动chromium browser及常见错误解析 (ubuntu18.04, 图形界面)](https://www.cnblogs.com/freestylesoccor/articles/9630758.html)

[解决 canberra-gtk-module 加载失败的问题](https://blog.csdn.net/Longyu_wlz/article/details/85254588)

[VSCode: There is no Pip installer available in the selected environment](https://stackoverflow.com/questions/50993566/vscode-there-is-no-pip-installer-available-in-the-selected-environment)

启动`docker`:

```
$ docker run -d \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix${DISPLAY} \
-e LOCAL_USER_ID=`id -u ${USER}` \
-e XMODIFIERS="@im=fcitx" \
-e QT_IM_MODULE="fcitx" \
-e GTK_IM_MODULE="fcitx" \
-v ${HOME}/docs:/home/user/docs \
--name code \
code:v1
```

## 问题

`vscode`无法输入中文,以及中文显示乱码问题?

通过`docker exec`进入容器,可以在命令行输入和显示中文
7 changes: 4 additions & 3 deletions dockerfiles/code/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ then
USER_ID=${LOCAL_USER_ID:-9001}

usermod -u ${USER_ID} -g ${USER_ID} -a -G root user
chown -R `id -u user`:`id -u user` /app
chown -R `id -u user`:`id -g user` /app

service dbus start
export HOME=/home/user
exec gosu user "$0"
exec gosu user "$0" "$@"
fi

exec /usr/bin/code --verbose
exec $@

0 comments on commit e639dbe

Please sign in to comment.