From 438f5c8b081e1df260035f709fc16a92b0f34af7 Mon Sep 17 00:00:00 2001
From: Bessa
Date: Wed, 11 Dec 2024 16:44:14 -0300
Subject: [PATCH] =?UTF-8?q?feat:=20dockeriza=C3=A7=C3=A3o=20do=20front-end?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.dockerignore | 34 +++++++++++++++++++++++++++++++
README.Docker.md | 22 ++++++++++++++++++++
app/static/css/style.css | 0
app/views/html/index.html | 0
compose.yaml | 15 ++++++++++++++
frontend/vite-project/Dockerfile | 22 ++++++++++++++++++++
frontend/vite-project/src/App.tsx | 2 +-
7 files changed, 94 insertions(+), 1 deletion(-)
create mode 100644 .dockerignore
create mode 100644 README.Docker.md
delete mode 100644 app/static/css/style.css
delete mode 100644 app/views/html/index.html
create mode 100644 compose.yaml
create mode 100644 frontend/vite-project/Dockerfile
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..dc157ff1
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,34 @@
+# Include any files or directories that you don't want to be copied to your
+# container here (e.g., local build artifacts, temporary files, etc.).
+#
+# For more help, visit the .dockerignore file reference guide at
+# https://docs.docker.com/go/build-context-dockerignore/
+
+**/.classpath
+**/.dockerignore
+**/.env
+**/.git
+**/.gitignore
+**/.project
+**/.settings
+**/.toolstarget
+**/.vs
+**/.vscode
+**/.next
+**/.cache
+**/*.*proj.user
+**/*.dbmdl
+**/*.jfm
+**/charts
+**/docker-compose*
+**/compose.y*ml
+**/Dockerfile*
+**/node_modules
+**/npm-debug.log
+**/obj
+**/secrets.dev.yaml
+**/values.dev.yaml
+**/build
+**/dist
+LICENSE
+README.md
diff --git a/README.Docker.md b/README.Docker.md
new file mode 100644
index 00000000..8300f21d
--- /dev/null
+++ b/README.Docker.md
@@ -0,0 +1,22 @@
+### Building and running your application
+
+When you're ready, start your application by running:
+`docker compose up --build`.
+
+Your application will be available at http://localhost:5173.
+
+### Deploying your application to the cloud
+
+First, build your image, e.g.: `docker build -t myapp .`.
+If your cloud uses a different CPU architecture than your development
+machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
+you'll want to build the image for that platform, e.g.:
+`docker build --platform=linux/amd64 -t myapp .`.
+
+Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.
+
+Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
+docs for more detail on building and pushing.
+
+### References
+* [Docker's Node.js guide](https://docs.docker.com/language/nodejs/)
\ No newline at end of file
diff --git a/app/static/css/style.css b/app/static/css/style.css
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/views/html/index.html b/app/views/html/index.html
deleted file mode 100644
index e69de29b..00000000
diff --git a/compose.yaml b/compose.yaml
new file mode 100644
index 00000000..f94242b4
--- /dev/null
+++ b/compose.yaml
@@ -0,0 +1,15 @@
+services:
+ server:
+ build:
+ context: ./frontend/vite-project
+ environment:
+ NODE_ENV: production
+ ports:
+ - 5173:5173
+ develop:
+ watch:
+ - path: ./frontend/vite-project/package.json
+ action: rebuild
+ - path: ./frontend/vite-project
+ target: /usr/src/app
+ action: sync
diff --git a/frontend/vite-project/Dockerfile b/frontend/vite-project/Dockerfile
new file mode 100644
index 00000000..5a98652f
--- /dev/null
+++ b/frontend/vite-project/Dockerfile
@@ -0,0 +1,22 @@
+# Dockerfile
+
+# Use uma imagem base do Node.js
+FROM node:18
+
+# Defina o diretório de trabalho no contêiner
+WORKDIR /usr/src/app
+
+# Copie os arquivos do package.json e package-lock.json
+COPY package*.json ./
+
+# Instale as dependências do projeto
+RUN npm install
+
+# Copie o restante do projeto para o diretório de trabalho
+COPY . .
+
+# Exponha a porta padrão do Vite (geralmente é 5173)
+EXPOSE 5173
+
+# Comando padrão para iniciar o Vite
+CMD npm run dev -- --host
diff --git a/frontend/vite-project/src/App.tsx b/frontend/vite-project/src/App.tsx
index 3d7ded3f..40856275 100644
--- a/frontend/vite-project/src/App.tsx
+++ b/frontend/vite-project/src/App.tsx
@@ -26,7 +26,7 @@ function App() {
- Click on the Vite and React logos to learn more
+ Click on the Vite and React to learn more
>
)