Skip to content

Commit 354b42f

Browse files
committed
jj
1 parent 351f05a commit 354b42f

4 files changed

Lines changed: 109 additions & 0 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
3+
{
4+
"name": "Existing Dockerfile",
5+
"build": {
6+
// Sets the run context to one level up instead of the .devcontainer folder.
7+
"context": "..",
8+
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9+
"dockerfile": "../Dockerfile"
10+
},
11+
12+
// Features to add to the dev container. More info: https://containers.dev/features.
13+
// "features": {},
14+
15+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
16+
"forwardPorts": [55555],
17+
18+
// Uncomment the next line to run commands after the container is created.
19+
// "postCreateCommand": "cat /etc/os-release",
20+
21+
// Configure tool-specific properties.
22+
// "customizations": {},
23+
24+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
25+
"remoteUser": "dev",
26+
"remoteEnv": {
27+
"USE_CN_MIRROR": "true"
28+
}
29+
}

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# 使用opensuse/tumbleweed作为基础镜像
2+
FROM opensuse/tumbleweed
3+
4+
RUN zypper mr -da
5+
6+
# 替换zypper的源为国内镜像(清华大学)
7+
# RUN zypper ar -fcg 'https://mirrors.ustc.edu.cn/opensuse/tumbleweed/repo/oss' USTC:OSS
8+
# RUN zypper ar -fcg 'https://mirrors.ustc.edu.cn/opensuse/tumbleweed/repo/non-oss' USTC:NON-OSS
9+
# RUN zypper ar -fcg 'https://mirrors.ustc.edu.cn/opensuse/update/tumbleweed' USTC:UPDATE
10+
11+
# 定义一个环境变量,国内镜像
12+
ARG DEFAULT_CN_MIRROR=https://mirrors.ustc.edu.cn
13+
14+
ENV USE_CN_MIRROR=false;
15+
16+
# 根据环境变量设置镜像源
17+
RUN if [ $USE_CN_MIRROR == true ]; then \
18+
19+
echo "Using China mirror..." && \
20+
21+
zypper ar -fcg '${CN_MIRROR:-$DEFAULT_CN_MIRROR}/opensuse/tumbleweed/repo/oss/' OSS && \
22+
23+
zypper ar -fcg '${CN_MIRROR:-$DEFAULT_CN_MIRROR}/opensuse/tumbleweed/repo/non-oss' NON-OSS && \
24+
25+
zypper ar -fcg '${CN_MIRROR:-$DEFAULT_CN_MIRROR}/opensuse/update/tumbleweed' UPDATE; \
26+
27+
else \
28+
29+
echo "Using default repositories..."; \
30+
31+
fi
32+
33+
# 刷新
34+
RUN zypper refresh
35+
36+
# 安装基本依赖
37+
RUN zypper install -y bash-completion gawk unzip curl
38+
39+
# 安装hcpp依赖
40+
RUN zypper install -y clang spdlog-devel asio-devel openssl
41+
42+
# 安装xmake依赖
43+
RUN zypper install -y readline-devel git
44+
RUN zypper install -y -t pattern devel_C_C++
45+
46+
# 添加dev用户(出于安全考虑,不推荐在Dockerfile中硬编码密码)
47+
RUN useradd -ms /bin/bash dev
48+
49+
# 切换到dev用户
50+
USER dev
51+
52+
# 安装xmake https://xmake.io/#/zh-cn/guide/installation
53+
RUN curl -fsSL https://xmake.io/shget.text | bash
54+
55+
# 如果需要,可以设置环境变量
56+
# ENV VARIABLE_NAME=value
57+
58+
# 定义容器启动时运行的命令(可选)
59+
# CMD ["executable","param1","param2"]
60+
61+
# 容器启动时以非root用户运行(可选,但更安全)
62+
# USER dev

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,9 @@ curl -i -x http://localhost:55555 -v --cacert ~/.config/hcpp/ca.cert.pem 'https
6060
```shell
6161
curl -i -x http://localhost:55555 -vk 'https://gitee.com'
6262
```
63+
64+
### 开发(DEV)
65+
66+
通常,编译要求满足后不需要其他配置,不过你可以通过使用vscode的dev container在docker容器中进行开发,那么点击下面的连接
67+
68+
If you already have VS Code and Docker installed, you can click the badge [here](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/dayu521/hcpp) to get started

0 commit comments

Comments
 (0)