Skip to content

Commit 223ec5c

Browse files
chore: Add Dockerfile for Alpine image with Nginx and index.html
1 parent 6afc97a commit 223ec5c

File tree

10 files changed

+171
-0
lines changed

10 files changed

+171
-0
lines changed

Diff for: alpine/Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Etapa 1: Construção
2+
FROM alpine:3.18 AS builder
3+
4+
RUN apk update && apk add --no-cache nginx
5+
6+
COPY index.html /var/www/html/
7+
8+
# Etapa 2: Imagem final
9+
FROM alpine:3.18
10+
11+
COPY --from=builder /etc/nginx /etc/nginx
12+
COPY --from=builder /usr/sbin/nginx /usr/sbin/nginx
13+
COPY --from=builder /var/www/html /var/www/html
14+
15+
EXPOSE 80
16+
17+
WORKDIR /var/www/html/
18+
19+
CMD ["nginx", "-g", "daemon off;"]
20+
21+
ENV APP_VERSION 1.0.0

Diff for: alpine/index.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Programa Intensivo em Containers e Kubernetes da LINUXtips</title>
6+
</head>
7+
8+
<body>
9+
<h1>Programa Intensivo em Containers e Kubernetes da LINUXtips!</h1>
10+
11+
<p>Com o Programa Intensivo em Containers e Kubernetes da LINUXtips, voce tera acesso a uma formacao completa e
12+
totalmente pratica, que nao apenas transfere conhecimento, mas tambem prepara voce para enfrentar desafios reais
13+
no mundo real.</p>
14+
15+
16+
<p>Confira o meu repositorio no GitHub: <a href="https://github.com/Tech-Preta/pick"
17+
target="_blank">https://github.com/Tech-Preta/pick</a></p>
18+
</body>
19+
20+
</html>

Diff for: distroless/Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM cgr.dev/chainguard/python:latest-dev as builder
2+
3+
ENV LANG=C.UTF-8
4+
ENV PYTHONDONTWRITEBYTECODE=1
5+
ENV PYTHONUNBUFFERED=1
6+
ENV PATH="/linky/venv/bin:$PATH"
7+
8+
WORKDIR /linky
9+
10+
RUN python -m venv /linky/venv
11+
COPY requirements.txt .
12+
13+
RUN pip install --no-cache-dir -r requirements.txt
14+
15+
FROM cgr.dev/chainguard/python:latest
16+
17+
WORKDIR /linky
18+
19+
ENV PYTHONUNBUFFERED=1
20+
ENV PATH="/venv/bin:$PATH"
21+
22+
COPY linky.py linky.png ./
23+
COPY --from=builder /linky/venv /venv
24+
25+
ENTRYPOINT [ "python", "/linky/linky.py" ]

Diff for: distroless/linky.png

69.4 KB
Loading

Diff for: distroless/linky.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'''import climage module to display images on terminal'''
2+
from climage import convert
3+
4+
5+
def main():
6+
'''Take in PNG and output as ANSI to terminal'''
7+
output = convert('linky.png', is_unicode=True)
8+
print(output)
9+
10+
if __name__ == "__main__":
11+
main()

Diff for: distroless/requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
setuptools==68.2.2
2+
climage==0.2.0

Diff for: multi-stage/Dockerfile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
# Etapa 1: Construção
3+
FROM ubuntu:22.04 AS builder
4+
# A instrução FROM especifica a imagem base para a etapa de construção.
5+
# Neste caso, utiliza a imagem do Ubuntu 22.04 como base.
6+
7+
# Instala o servidor web Nginx e outras dependências necessárias
8+
RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/*
9+
# Este comando Dockerfile instala o servidor web Nginx no contêiner.
10+
# Ele atualiza o sistema operacional e, em seguida, usa o comando apt-get para instalar o pacote nginx.
11+
# O parâmetro "-y" é usado para confirmar automaticamente todas as perguntas de instalação.
12+
# Por fim, o comando "rm -rf /var/lib/apt/lists/*" remove os arquivos de lista de pacotes desnecessários para economizar espaço em disco.
13+
14+
# Copia o arquivo index.html para o diretório /var/www/html/ dentro do container
15+
COPY index.html /var/www/html/
16+
17+
# Etapa 2: Imagem final
18+
FROM ubuntu:22.04
19+
# A instrução FROM especifica a imagem base para a imagem final.
20+
# Neste caso, utiliza a imagem do Ubuntu 22.04 como base.
21+
22+
# Copia o Nginx instalado e o arquivo index.html da etapa de construção para a imagem final
23+
COPY --from=builder /etc/nginx /etc/nginx
24+
COPY --from=builder /usr/sbin/nginx /usr/sbin/nginx
25+
COPY --from=builder /var/www/html /var/www/html
26+
27+
# Expõe a porta 80 para tráfego HTTP.
28+
EXPOSE 80
29+
30+
# Define o diretório de trabalho como /var/www/html/ dentro do container
31+
WORKDIR /var/www/html/
32+
33+
# O comando CMD especifica o comando a ser executado quando o contêiner é iniciado.
34+
# Neste caso, inicia o servidor Nginx com a opção "daemon off;", que mantém o processo em execução em primeiro plano.
35+
CMD ["nginx", "-g", "daemon off;"]
36+
37+
# Define a variável de ambiente APP_VERSION com o valor 1.0.0.
38+
ENV APP_VERSION 1.0.0

Diff for: multi-stage/index.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Programa Intensivo em Containers e Kubernetes da LINUXtips</title>
6+
</head>
7+
8+
<body>
9+
<h1>Programa Intensivo em Containers e Kubernetes da LINUXtips!</h1>
10+
11+
<p>Com o Programa Intensivo em Containers e Kubernetes da LINUXtips, voce tera acesso a uma formacao completa e
12+
totalmente pratica, que nao apenas transfere conhecimento, mas tambem prepara voce para enfrentar desafios reais
13+
no mundo real.</p>
14+
15+
16+
<p>Confira o meu repositorio no GitHub: <a href="https://github.com/Tech-Preta/pick"
17+
target="_blank">https://github.com/Tech-Preta/pick</a></p>
18+
</body>
19+
20+
</html>

Diff for: traditional/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
FROM ubuntu:18.04
3+
4+
RUN apt-get update && apt-get install nginx -y && rm -rf /var/lib/apt/lists/*
5+
6+
EXPOSE 80
7+
8+
COPY index.html /var/www/html/
9+
10+
WORKDIR /var/www/html/
11+
12+
CMD ["nginx", "-g", "daemon off;"]
13+
14+
ENV APP_VERSION 1.0.0

Diff for: traditional/index.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Programa Intensivo em Containers e Kubernetes da LINUXtips</title>
6+
</head>
7+
8+
<body>
9+
<h1>Programa Intensivo em Containers e Kubernetes da LINUXtips!</h1>
10+
11+
<p>Com o Programa Intensivo em Containers e Kubernetes da LINUXtips, voce tera acesso a uma formacao completa e
12+
totalmente pratica, que nao apenas transfere conhecimento, mas tambem prepara voce para enfrentar desafios reais
13+
no mundo real.</p>
14+
15+
16+
<p>Confira o meu repositorio no GitHub: <a href="https://github.com/Tech-Preta/pick"
17+
target="_blank">https://github.com/Tech-Preta/pick</a></p>
18+
</body>
19+
20+
</html>

0 commit comments

Comments
 (0)