-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
86 lines (67 loc) · 1.9 KB
/
Dockerfile
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# syntax=docker/dockerfile:1.5
FROM ubuntu:lunar-20230128
ARG USERNAME
ENV USERNAME=${USERNAME:-dev}
ENV HELM_EXPERIMENTAL_OCI=1
# Versions
ENV GCLOUD_CLI_VERSION=419.0.0
ENV GO_VERSION=1.20.1
ENV KNATIVE_CLI_VERSION=1.9.0
ENV TERRAFORM_VERSION=1.3.9
USER root
SHELL ["bash", "-c"]
COPY --chown=ubuntu:ubuntu ./user_setup.zsh /home/ubuntu/user_setup.zsh
WORKDIR /root
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked <<BLOCK
set -euo pipefail
sed -i -r 's/# deb-src/deb-src/g' /etc/apt/sources.list
apt-get update
# Tools to keep:
apt-get install -y \
build-essential \
curl \
fzf \
git \
lsb-release \
postgresql-client \
python-is-python3 \
python3 \
python3-pip \
python3-venv \
sudo \
tmux \
unzip \
wget \
zsh
apt build-dep -y python3
pip install pipx
echo "" >> /etc/sudoers && echo '%sudo ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers
apt autoremove && apt autoclean
# Rename the user
groupmod -n $USERNAME ubuntu && usermod -l $USERNAME -md /home/$USERNAME ubuntu
usermod -aG sudo \
--shell /usr/bin/zsh \
$USERNAME
runuser -l $USERNAME <<USER_BLOCK
set -euo pipefail
export GCLOUD_CLI_VERSION=$GCLOUD_CLI_VERSION
export GO_VERSION=$GO_VERSION
export KNATIVE_CLI_VERSION=$KNATIVE_CLI_VERSION
export TERRAFORM_VERSION=$TERRAFORM_VERSION
sudo chown -R 1000:1000 .
zsh ./user_setup.zsh && rm user_setup.zsh
USER_BLOCK
rm -rf /tmp/* /root/.cache /root/.local
BLOCK
# using build args is a little more user friendly on build commands
USER $USERNAME
WORKDIR /home/$USERNAME
COPY --chown=$USERNAME:$USERNAME ./.zshrc ./.zshrc
ENV USER=""
# Customize
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ENV ZSH_THEME jreese
# remove strictness
SHELL [ "/usr/bin/zsh", "-l", "-c" ]
ENTRYPOINT [ "/usr/bin/zsh", "-l" ]