-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
66 lines (54 loc) · 2.94 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
FROM debian:bookworm-slim
# Argumentos:
# --------------------------------------------------------------------------------------
ARG USER
ARG oh_my_zsh=https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
USER root
# Instala dependências e o PostgreSQL:
# --------------------------------------------------------------------------------------
RUN apt update && apt install -y postgresql procps tor torsocks dos2unix git sudo vim \
zsh vim curl net-tools nftables && apt clean
# Removendo apt lists:
# NOTA: Ao remover não conseguirá instalar mais pacotes. Descomente caso não queira
# instalar mais pacotes em sua imagem.
# --------------------------------------------------------------------------------------
# RUN rm -rf /var/lib/apt/lists/*
# Cria um novo usuário no sistema:
# --------------------------------------------------------------------------------------
RUN useradd -ms /bin/zsh $USER && usermod -aG sudo,users,postgres,debian-tor $USER
RUN echo "$USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
RUN chown -R ${USER}:${USER} /home/${USER}
# Instalado Starship:
# --------------------------------------------------------------------------------------
RUN curl -sS https://starship.rs/install.sh | sh -s -- -y
# Copia scripts para o container:
# --------------------------------------------------------------------------------------
RUN mkdir -p /usr/local/entrypoint
COPY ./entrypoint/* /usr/local/entrypoint/
COPY ./config/nftables.conf /etc/nftables.conf
COPY ./config/pg_hba.conf /opt/pg_hba.conf
COPY ./config/postgresql.conf /opt/postgresql.conf
COPY ./config/torctl.sh /etc/init.d/torctl
# Dá permissão de execução aos scripts:
# --------------------------------------------------------------------------------------
RUN chmod +x /usr/local/entrypoint/entrypoint.sh /usr/local/entrypoint/sql.sh \
/usr/local/entrypoint/firewall.sh /etc/init.d/torctl
# Converte arquivos para LF (do sistema):
# --------------------------------------------------------------------------------------
RUN dos2unix /usr/local/entrypoint/entrypoint.sh /opt/pg_hba.conf /opt/postgresql.conf
# Entra no usuário criado:
# --------------------------------------------------------------------------------------
USER $USER
# Instala o Oh-My-ZSH e plugins (opcional):
# --------------------------------------------------------------------------------------
RUN sh -c "$(curl -fsSL $oh_my_zsh)"
RUN echo "eval \"\$(starship init zsh)\"" > \
/home/${USER}/.oh-my-zsh/custom/themes/starship.zsh-theme
RUN git clone https://github.com/zsh-users/zsh-autosuggestions \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
RUN git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
COPY ./config/.zshrc /home/${USER}/.zshrc
# Define o entrypoint:
# --------------------------------------------------------------------------------------
ENTRYPOINT ["zsh", "/usr/local/entrypoint/entrypoint.sh"]