目的
以前、dockerで同じ様な環境を作ったが開発環境としては物足りない部分があった。LXD上で構築すれば解決すると考えた
構築
lxdfile
CONTAINERNAME ubuntu-go
FROM ubuntu/23.04
RUN export DEBIAN_FRONTEND=noninteractive
RUN timedatectl set-timezone Asia/Tokyo && hostnamectl set-hostname ubuntu-go
RUN apt-get -y update
RUN dpkg --configure -a
RUN echo "\n\n\n" | apt-get -y install openssh-server
RUN apt-get -y install docker docker.io docker-compose nano curl
RUN echo -e "root:password" | chpasswd
RUN echo -e 'PermitRootLogin yes' >> /etc/ssh/sshd_config
RUN systemctl enable ssh
RUN systemctl restart ssh
RUN systemctl start ssh
RUN apt-get -y update && apt-get -y install python3-pip nano
RUN mkdir .pip
RUN touch .pip/pip.conf
RUN echo "[global]" >> .pip/pip.conf
RUN echo "break-system-packages = true" >> .pip/pip.conf
RUN wget https://go.dev/dl/go1.20.4.linux-arm64.tar.gz
RUN mkdir -p /usr/local/go/bin
RUN tar -C /usr/local -xzf go1.20.4.linux-arm64.tar.gz
ENV PATH $PATH:/usr/local/go/bin
RUN export PATH=$PATH:/usr/local/go/bin
RUN echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bashrc
確認
go
root@ubuntu-go:~# go
Go is a tool for managing Go source code.
Usage:
go <command> [arguments]
The commands are:
bug start a bug report
build compile packages and dependencies
clean remove object files and cached files
doc show documentation for package or symbol
env print Go environment information
fix update packages to use new APIs
fmt gofmt (reformat) package sources
generate generate Go files by processing source
get add dependencies to current module and install them
install compile and install packages and dependencies
list list packages or modules
mod module maintenance
work workspace maintenance
run compile and run Go program
test test packages
tool run specified go tool
version print Go version
vet report likely mistakes in packages
Use "go help <command>" for more information about a command.
python
root@ubuntu-go:~# python3
Python 3.11.4 (main, Jun 9 2023, 07:59:55) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>