-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd6a4a8
commit d0e79ba
Showing
9 changed files
with
72 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# Cria a pasta bin se não existir | ||
mkdir -p bin | ||
|
||
# Compila o código da pasta src usando gcc e libmicrohttpd, e coloca o executável na pasta bin | ||
gcc -o bin/main src/main.c -lmicrohttpd | ||
|
||
# Verifica se a compilação foi bem-sucedida | ||
if [ $? -eq 0 ]; then | ||
echo "Compilação bem-sucedida." | ||
else | ||
echo "Erro durante a compilação." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Nome do contêiner | ||
CONTAINER_NAME="rest-api-c" | ||
|
||
# Remove o contêiner existente com o mesmo nome | ||
docker rm -f "$CONTAINER_NAME" >/dev/null 2>&1 | ||
|
||
# Constrói a imagem do Docker a partir do Dockerfile | ||
docker build -t rest-api-c . | ||
|
||
# Executa o contêiner, expondo a porta 8080 e atribuindo o nome "rest-api-c" | ||
docker run -d -p 8080:80 --name "$CONTAINER_NAME" rest-api-c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
FROM ubuntu:latest | ||
# Use uma imagem de base com suporte para compilação C | ||
FROM gcc:latest | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
libmicrohttpd-dev \ | ||
gcc \ | ||
make | ||
# Instale as dependências necessárias | ||
RUN apt-get update && \ | ||
apt-get install -y libmicrohttpd-dev make nginx | ||
|
||
RUN mkdir -p /app | ||
|
||
WORKDIR /app | ||
|
||
COPY . /app | ||
|
||
RUN ./build.sh | ||
|
||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
EXPOSE 80 | ||
|
||
CMD nginx -g "daemon off;" | ||
|
||
RUN ./bin/main | ||
|
||
# Rever execução do ./bin/main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
./build.sh | ||
|
||
echo "Executando o programa..." | ||
|
||
./bin/main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
worker_processes 1; | ||
events { worker_connections 1024; } | ||
|
||
http { | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
location / { | ||
proxy_pass http://127.0.0.1:8080; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters