-
Notifications
You must be signed in to change notification settings - Fork 0
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
675cb39
commit f88db1a
Showing
82 changed files
with
245 additions
and
187 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
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,2 +1,2 @@ | ||
/docker/dados_postgres | ||
/documents/* | ||
/backend/documents/* |
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,80 @@ | ||
# Etapa de build do frontend | ||
FROM node:14 AS build-frontend | ||
|
||
WORKDIR /app/frontend | ||
|
||
COPY frontend/package.json ./ | ||
COPY frontend/package-lock.json ./ | ||
|
||
RUN npm install | ||
|
||
COPY frontend ./ | ||
|
||
RUN npm run build | ||
|
||
# Use uma imagem oficial do Go como base | ||
FROM golang:1.22.5 AS build-backend | ||
|
||
# Configure o diretório de trabalho | ||
WORKDIR /app/backend | ||
|
||
# Copie o código-fonte para o contêiner | ||
COPY backend/go.mod ./ | ||
COPY backend/go.sum ./ | ||
RUN go mod download | ||
COPY backend ./ | ||
|
||
# Executa o comando de build | ||
RUN go build -o main . | ||
|
||
# Imagem base do Ubuntu | ||
FROM ubuntu:latest | ||
|
||
# Atualize os pacotes e instale o PostgreSQL, nginx, npm e nodejs | ||
RUN export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get update -q \ | ||
&& apt-get install -y -q postgresql postgresql-contrib nodejs npm nginx | ||
|
||
# Configurar o diretório de trabalho | ||
WORKDIR /root/ | ||
|
||
# Exponha o diretório de dados do PostgreSQL para persistência | ||
VOLUME /var/lib/postgresql/data | ||
|
||
# # Copie o binário do primeiro estágio | ||
# COPY --from=builder /app/main /app/main | ||
|
||
# Inicie o PostgreSQL e crie o banco de dados | ||
#su postgres -c 'createuser -s postgres' && \ | ||
RUN service postgresql start && \ | ||
su postgres -c 'createdb documentmanager' && \ | ||
su - postgres -c "psql -U postgres -c \"ALTER USER postgres WITH PASSWORD 'postgres';\"" | ||
|
||
|
||
# Combinando front, back e database | ||
|
||
# Copiar e configurar o backend | ||
COPY --from=build-backend /app/backend/main ./ | ||
|
||
# Copiar e configurar o frontend | ||
COPY --from=build-frontend /app/frontend/build /usr/share/nginx/html | ||
|
||
# Configurar Nginx | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Copiar o script de variáveis de ambiente | ||
COPY backend/.initENV.sh /root/.initENV.sh | ||
RUN chmod +x /root/.initENV.sh | ||
|
||
# Configurar PostgreSQL | ||
RUN mkdir -p /var/lib/postgresql/data | ||
RUN chown -R postgres:postgres /var/lib/postgresql | ||
|
||
# Instalar o serve para servir a aplicação React | ||
RUN npm install -g serve | ||
|
||
# Expor as portas necessárias | ||
EXPOSE 80 3450 5432 3000 | ||
|
||
# Comando para iniciar todos os serviços | ||
CMD ["sh", "-c", ". /root/.initENV.sh && service postgresql start && ./main & serve -n -s /usr/share/nginx/html -l 3000 & nginx -g 'daemon off;'"] |
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,76 +1,80 @@ | ||
# document-manager | ||
|
||
Go API para gerenciar documentos com frontend em React. | ||
Go API for managing documents with a React frontend. | ||
|
||
## Clone o Repositório | ||
## Clone the Repository | ||
|
||
```shell | ||
git clone https://github.com/Josehpequeno/document-manager.git | ||
cd document-manager | ||
``` | ||
|
||
## Executar última versão com docker-compose | ||
## Run the latest version with docker-compose | ||
|
||
```shell | ||
cd docker && docker-compose up -d | ||
``` | ||
|
||
Se os containers estiverem parados, execute o seguinte comando: | ||
If the containers are stopped, run the following command: | ||
|
||
```shell | ||
docker-compose start | ||
``` | ||
|
||
O Postgres estará rodando na porta 5432, o pgAdmin na porta 8080 e a aplicação na porta 3450 de acordo com as credenciais no arquivo docker-compose.yml. | ||
Postgres will run on port 5432, pgAdmin on port 8080, and the application on port 3450, according to the credentials in the docker-compose.yml file. | ||
|
||
## Iniciar variáveis de ambiente | ||
## Initialize environment variables | ||
|
||
```shell | ||
cd backend | ||
``` | ||
|
||
```shell | ||
chmod +x .initENV.sh && source .initENV.sh | ||
``` | ||
|
||
## Gerar Documentação Swagger | ||
## Generate Swagger Documentation | ||
|
||
### Instalar Swag | ||
### Install Swag | ||
|
||
```shell | ||
go install github.com/swaggo/swag/cmd/swag@latest | ||
``` | ||
|
||
### Executar Swag | ||
### Run Swag | ||
|
||
```shell | ||
swag init --parseDependency --parseInternal | ||
``` | ||
|
||
### Rota Swagger | ||
### Swagger Route | ||
|
||
A documentação Swagger pode ser acessada em [http://localhost:3450/swagger/index.html](http://localhost:3450/swagger/index.html). | ||
|
||
## Testes | ||
## Tests | ||
|
||
Testar handlers: | ||
Test handlers: | ||
|
||
```shell | ||
cd api/handlers/ && GIN_MODE=release go test | ||
``` | ||
|
||
## Requisitos do Sistema | ||
## System Requirements | ||
|
||
Certifique-se de ter o Docker e o Docker Compose instalados. | ||
Make sure you have Docker and Docker Compose installed. | ||
|
||
## Link para o Repositório no DockerHub | ||
## Link to repository on DockerHub | ||
|
||
A imagem Docker do projeto está disponível no [repositório do DockerHub](https://hub.docker.com/r/josehpequeno/document-manager). | ||
The project's Docker image is available in the [DockerHub repository](https://hub.docker.com/r/josehpequeno/document-manager). | ||
|
||
* Executar com Docker | ||
Para executar a aplicação com Docker, use o seguinte comando: | ||
* Run with Docker | ||
To run the application with Docker, use the following command: | ||
|
||
```shell | ||
docker run -it --name test-document-manager -p 8080:3450 -p 3000:3000 josehpequeno/document-manager:latest | ||
docker run -it --name test-document-manager -p 3450:3450 -p 3000:3000 josehpequeno/document-manager:latest | ||
``` | ||
Isso irá iniciar a aplicação no contêiner Docker e expor as portas 8080 e 3000 para os respectivos serviços. | ||
This will start the application in the Docker container and expose ports 8080 and 3000 to the respective services. | ||
|
||
## Licença | ||
## License | ||
|
||
Este projeto é licenciado sob a [MIT License](LICENSE). | ||
This project is licensed under the [MIT License](LICENSE). |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.