Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

golang development environment #32

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions dockerfile-kasm-ubuntu-focal-desktop-golang
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ARG BASE_TAG="1.11.0"
ARG BASE_IMAGE="ubuntu-focal-desktop"
FROM kasmweb/$BASE_IMAGE:$BASE_TAG

USER root

ENV HOME /home/kasm-default-profile
ENV STARTUPDIR /dockerstartup
WORKDIR $HOME

### Envrionment config
ENV DEBIAN_FRONTEND noninteractive
ENV KASM_RX_HOME $STARTUPDIR/kasmrx
ENV INST_SCRIPTS $STARTUPDIR/install

######### Customize Container Here ###########

### Install sudo cifs-utils inetutils-ping net-tools tools package
RUN apt-get update \
&& apt-get install -y sudo cifs-utils inetutils-ping net-tools iftop dnsutils iperf3 \
&& echo 'kasm-user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers \
&& rm -rf /var/lib/apt/list/*

### Install Golang and relevant extension for Visual Studio Code
COPY ./src/ubuntu/install/golang $INST_SCRIPTS/golang/
RUN bash $INST_SCRIPTS/golang/install_golang.sh

## Install vscode golang extensions, It will using none root user home directory to install for the convenience of updating.
USER 1000
RUN bash $INST_SCRIPTS/golang/install_vs_code_ext.sh
USER root
RUN rm -rf $INST_SCRIPTS/golang/

#ADD ./src/common/scripts $STARTUPDIR
RUN $STARTUPDIR/set_user_permission.sh $HOME

RUN chown 1000:0 $HOME

ENV HOME /home/kasm-user
WORKDIR $HOME
RUN mkdir -p $HOME && chown -R 1000:0 $HOME

USER 1000

CMD ["--tail-log"]
25 changes: 25 additions & 0 deletions src/ubuntu/install/golang/install_golang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -ex
ARCH=$(arch | sed 's/aarch64/arm64/g' | sed 's/x86_64/amd64/g')
GOVER='1.19.2'
# Remove any previous Go installation (if it exists), then extract the new archive into /usr/local
wget -q https://go.dev/dl/go${GOVER}.linux-${ARCH}.tar.gz -O golang.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf golang.tar.gz

# add /usr/local/go/bin to the PATH environment variable
export PATH=$PATH:/usr/local/go/bin
echo "PATH=\$PATH:/usr/local/go/bin" | tee -i /etc/bash.bashrc

# config go mod mirror site
go env -w GO111MODULE=on
#go env -w GOPROXY=https://goproxy.cn,direct # for china user only

# install go tools
go install golang.org/x/tools/gopls@latest
go install github.com/go-delve/delve/cmd/dlv@latest
go install github.com/josharian/impl@latest
#go get -u github.com/cweill/gotests/...

# clear up
go clean --modcache
rm -rf golang.tar.gz
11 changes: 11 additions & 0 deletions src/ubuntu/install/golang/install_vs_code_ext.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -ex

code --install-extension VisualStudioExptTeam.vscodeintellicode
code --install-extension golang.go
code --install-extension eamodio.gitlens
code --install-extension ms-vscode-remote.remote-containers
code --install-extension ms-kubernetes-tools.vscode-kubernetes-tools
code --install-extension ms-azuretools.vscode-docker
code --install-extension msyrus.go-doc
#code --install-extension 766b.go-outliner