目的
Goの環境を構築しろと言われることは多いと思う。今回はintel上でlxdcliを用いてgoの環境を構築しようと思う。
構築
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-amd64.tar.gz
RUN mkdir -p /usr/local/go/bin
RUN tar -C /usr/local -xzf go1.20.4.linux-amd64.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
ビルド
lxdcli build lxdfile