Code Server v4.8.3 容器镜像构建

Build Code Server for Golang

Posted by Alberthua on 2022-12-05

文档说明:

  • 🔗 可参考 该链接,以获得项目的 GitHub 仓库。
  • Red Hat OpenShift 中使用 Red Hat Code Ready Workspace 作为 PaaS 平台中的实时 IDE 开发平台,可兼容众多开发语言。
  • 该示例的目的在于构建类似于 Red Hat Code Ready Workspace 的容器化 Golang IDE 开发平台。
  • 可使用此 Golang IDE 开发平台提供与本地 Microsoft VS Code 平台相同的功能,并可实现实时登录开发环境与远程代码仓库的一致性。
  • 容器镜像构建与使用:

    • 该容器镜像可提供的功能:
      • 👉 基于 VS CodeWeb UI 开发界面
      • 👉 集成 Golang v1.19.3 语言开发环境
    • 使用该目录中的 Dockerfile 构建 Code Server v4.8.3 容器镜像,如下所示:
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      $ tree -h .
      .
      ├── [103M] code-server_4.8.3_amd64.deb
      ├── [1.9K] Dockerfile
      ├── [ 17K] oh-my-zsh-install.sh
      ├── [1.3K] README.md
      └── [ 614] sources.list

      $ sudo docker build -t golang-code-server:v1.1 .
      # 在当前目录上下文中构建
      $ sudo docker run -d --name=golang-code-server -p 8080:8080 golang-code-server:v1.1
      # 使用构建的容器镜像运行容器,并登录访问 Web 界面。

    💥 注意:由于 code-server_4.8.3_amd64.deb 软件包的容量大小限制无法上传至 GitHub 中,可从 百度网盘 下载,提取码为 no8o

    • 该容器镜像可在 KubernetesOpenShift 集群外使用 DockerPodman 先行测试,再导入容器镜像仓库 registry,用于后续的部署使用。
  • 可使用如下所示的 资源定义文件,将该应用部署于 KubernetesOpenShift 集群中:
    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
    apiVersion: v1
    kind: Service
    metadata:
    labels:
    name: golang-codeready-workspace
    name: golang-codeready-workspace
    namespace: codeready-workspace
    spec:
    ports:
    # the port that this service should serve on
    - port: 8080
    protocol: TCP
    targetPort: 8080
    nodePort: 30001
    # label keys and values that must match in order to receive traffic for this service
    selector:
    app: golang-codeready-workspace
    type: NodePort
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    labels:
    app: golang-codeready-workspace
    name: golang-codeready-workspace
    namespace: codeready-workspace
    spec:
    replicas: 1
    selector:
    matchLabels:
    app: golang-codeready-workspace
    template:
    metadata:
    creationTimestamp: null
    labels:
    app: golang-codeready-workspace
    spec:
    containers:
    - image: quay-registry.lab.example.com/godev/golang-code-server:v1.1
    # image also pulled from quay.io/alberthua/golang-code-server:v1.1
    imagePullPolicy: IfNotPresent
    name: golang-codeready-workspace
    ports:
    - containerPort: 8080
    protocol: TCP
    restartPolicy: Always
    schedulerName: default-scheduler
    securityContext: {}
    terminationGracePeriodSeconds: 30

参考链接: