Skip to content

Commit

Permalink
Codespaces (#181)
Browse files Browse the repository at this point in the history
* Fix: EOF standard

* New: Create multiple docker-compose to manage different configurations

* New:Adding dev containers configurations

* Update: Documentation

* New: Adding github codespaces

---------

Co-authored-by: Genesis Alvarez <[email protected]>
Co-authored-by: Marluan Espiritusanto <[email protected]>
  • Loading branch information
3 people authored Mar 13, 2024
1 parent 2f26c23 commit f71e957
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 5 deletions.
78 changes: 78 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"name": "Cuenta Única Ciudadana",
"image": "node:lts",
"hostRequirements": {
"cpus": 5
},
"waitFor": "onCreateCommand",
"postAttachCommand": {
"server": "npm i"
},
"postCreateCommand": "npm install --no-package-lock",
"forwardPorts": [3000],
"portsAttributes": {
"3000": {
"label": "Application",
"onAutoForward": "openPreview"
}
},
"secrets": {
"PORT": {
"description": "The port where the server will be running"
},
"AMPLIFY_WEBCLIENT_ID": {
"description": "The ID for the app client to be used by web applications"
},
"AWS_EXPORTS_JS": {
"description": "Configuration file generated by the Amplify CLI tool when you initialize an AWS Amplify project"
},
"AWS_EXPORTS_JSON": {
"description": "JSON file that contains configuration settings and environment variables related to AWS services within a specific project"
},
"CEDULA_API": {
"description": "API endpoint responsible for operations related to user identity"
},
"CEDULA_API_KEY": {
"description": "Authentication token or key used to access the API related to user identity"
},
"CEDULA_TOKEN_API": {
"description": "Authentication token used to access the API related to user identity"
},
"CITIZENS_API_AUTH_KEY": {
"description": "Authentication key used to access the API related to user identity"
},
"ENCRYPTION_KEY": {
"description": "Key used for encrypting and decrypting data"
},
"JCE_PHOTO_API": {
"description": "API endpoint responsible for operations related to user identity"
},
"JCE_PHOTO_API_KEY": {
"description": "Authentication key used to access the API related to user identity"
},
"NEXT_PUBLIC_GOOGLE_ANALYTICS": {
"description": "Used in Next.js applications to configure Google Analytics integration"
},
"NEXT_PUBLIC_RECAPTCHA_SITE_KEY": {
"description": "Site key for integrating Google reCAPTCHA into a Next.js application"
},
"ORY_SDK_TOKEN": {
"description": "Authentication token or access token used in conjunction with the ORY SDK"
},
"ORY_SDK_URL": {
"description": "URL endpoint of an ORY software development kit (SDK)"
},
"PWNED_KEY": {
"description": "Authentication key used to access the Have I Been Pwned (HIBP) service"
},
"RECAPTHA_API_KEY": {
"description": "Key used for integrating reCAPTCHA services into web applications"
},
"SENTRY_AUTH_TOKEN": {
"description": "Authentication token used in the context of the Sentry error monitoring and tracking platform"
},
"SITE_COOKIE_KEY": {
"description": "Used in web development to manage and manipulate cookies within a website or web application"
}
}
}
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-l
# Rebuild the source code only when needed
FROM base AS build

RUN <<EOF
apt-get update
apt-get install -y ca-certificates
rm -rf /var/lib/apt/lists/*
EOF
RUN apt-get update \
&& apt-get install -y ca-certificates \
&& rm -rf /var/lib/apt/lists/*

COPY --from=deps ${WORK_DIR}/node_modules ./node_modules
COPY . .
Expand Down
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,58 @@ Este proyecto depende de las siguientes recursos externos:
- Interoperabilidad: [X-Road](https://x-road.global/)
- Hosting: [Google Cloud Platform](https://cloud.google.com/)

## Pasos para utilizar contenedores de desarrollo

### Requisitos:

* Visual Studio Code: instale [VS Code](https://code.visualstudio.com/) .
* Docker: asegúrese de que [Docker](https://www.docker.com/products/docker-desktop/) esté instalado en su máquina.
* Extensiones de VS Code: instale la extensión ["Dev Containers"](https://code.visualstudio.com/docs/devcontainers/tutorial) en VS Code.

### Configuración del contenedor de desarrollo:

Dentro de su espacio de trabajo de `VS Code`, existe una carpeta llamada `.devcontainer`.
Dentro de esta carpeta, existe un archivo llamado `devcontainer.json` que se utiliza para definir la configuración del contenedor.
Se deben de hacer los ajustes necesarios como Dockerfile, Docker Compose, puertos, montajes de volumen, variables de entorno, etc.

### Ejecute el contenedor de desarrollo:

* Abra su proyecto en `VS Code`.
* Ejecute la paleta de comandos de VS Code (`Ctrl+Shift+P` o `Cmd+Shift+P`) y seleccione el comando `"Dev Containers: Open Folder in Container"`.
* Seleccione el espacio de trabajo que contiene la configuración del contenedor definida en la carpeta `.devcontainer`.

### Configuración de depuración:

Dentro de su espacio de trabajo de `VS Code`, existe un archivo llamado `launch.json` ubicado en la carpeta `.vscode`.
Este archivo contiene las configuraciones para depurar su aplicación específica.

### Ejecute la aplicación en modo de depuración:

* Dirijase al apartado Run and Debug in Visual Studio Code o presione `Ctrl+Shift+D`
* Seleccione la opción de debug en la lista desplegable.
* Haga clic en el botón "Iniciar depuración" o presione `F5`. Si desea reiniciar la depuración presione `Ctrl+Shift+F5`
* Esto debería iniciar su aplicación dentro del contenedor Docker y permitirle depurarla.

### Detener el contenedor de desarrollo

Para detener un contenedor de desarrollo en Visual Studio Code, puede seguir estos pasos:

* Abra la paleta de comandos presionando `Ctrl+Shift+P` (Windows/Linux) o `Cmd+Shift+P` (Mac).
* Escriba y seleccione `"Remote: Close Remote Conenction"`.

Alternativamente, puede ir a la esquina inferior derecha de la ventana de VS Code donde verá el ícono verde "><". Al hacer clic en él, se mostrará el Explorador remoto. Desde allí, puede hacer clic derecho en el contenedor asociado con su proyecto y seleccionar `"Remote: Close Remote Conenction"`. Esta acción detendrá el contenedor asociado con su proyecto. Si desea iniciarlo de nuevo, puede utilizar el comando `"Dev Containers: Open Folder in Container"`.

Tener en cuenta que detener el contenedor no lo eliminará; simplemente lo detiene. Si desea eliminar el contenedor por completo, puede hacerlo usando los comandos de Docker en la terminal o usando una herramienta GUI de Docker.


## Autor/es

- **Gustavo Valverde** - _Product Manager_ - [@gustavovalverde](https://github.com/gustavovalverde)
- **Marluan Espiritusanto** - *Technical Lead* - [@marluanespiritusanto](https://github.com/marluanespiritusanto)
- **José Álvarez** - *Developer* - [@JE1999](https://github.com/JE1999)
- **Jeffrey Mesa** - *Developer* - [@jeffreyart1](https://github.com/jeffreyart1)
- **Deyvison García** - _UI/UX Designer_ - [@DeyvisonGarcia](https://github.com/DeyvisonGarcia)
- **Genesis Alvarez** - *DevOps* - [@UsernameAlvarez](https://github.com/UsernameAlvarez)

## Información adicional

Expand Down
36 changes: 36 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.9'

services:
cuenta_unica:
container_name: cuenta_unica
image: node
environment:
- CEDULA_API
- CEDULA_API_KEY
- JCE_PHOTO_API
- JCE_PHOTO_API_KEY
- ENCRYPTION_KEY
- RECAPTHA_API_KEY
- RECAPTHA_PROJECT_ID
- SITE_COOKIE_KEY
- NEXT_PUBLIC_RECAPTCHA_SITE_KEY
- NEXT_PUBLIC_GOOGLE_ANALYTICS
- CEDULA_TOKEN_API
- CITIZENS_API_AUTH_KEY
- ORY_SDK_URL
- NEXT_PUBLIC_ORY_SDK_URL
- ORY_SDK_TOKEN
- NEXT_PUBLIC_API_MOCKING
- LIVENESS_THRESHOLD_VALUE
- LIVENESS_SIMILARIY_VALUE
volumes:
- .:/app
ports:
- 3000:3000
networks:
- cuenta_unica_network
tty: true

networks:
cuenta_unica_network:
driver: bridge
41 changes: 41 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.9'
services:
cuenta_unica:
container_name: cuenta_unica
build:
context: .
dockerfile: Dockerfile
args:
- SENTRY_ORG
- SENTRY_PROJECT
- SENTRY_AUTH_TOKEN
- NEXT_PUBLIC_SENTRY_DSN
- NEXT_PUBLIC_RECAPTCHA_SITE_KEY
restart: unless-stopped
networks:
- cuenta_unica_network
ports:
- 3000:3000
environment:
- CEDULA_API
- CEDULA_API_KEY
- JCE_PHOTO_API
- JCE_PHOTO_API_KEY
- ENCRYPTION_KEY
- RECAPTHA_API_KEY
- RECAPTHA_PROJECT_ID
- SITE_COOKIE_KEY
- NEXT_PUBLIC_RECAPTCHA_SITE_KEY
- NEXT_PUBLIC_GOOGLE_ANALYTICS
- CEDULA_TOKEN_API
- CITIZENS_API_AUTH_KEY
- ORY_SDK_URL
- NEXT_PUBLIC_ORY_SDK_URL
- ORY_SDK_TOKEN
- NEXT_PUBLIC_API_MOCKING
- LIVENESS_THRESHOLD_VALUE
- LIVENESS_SIMILARIY_VALUE
- SENTRY_LOG_LEVEL=debug

networks:
cuenta_unica_network:

0 comments on commit f71e957

Please sign in to comment.