|
1 | | -# Development setup |
| 1 | +# Configuración para desarrollo |
2 | 2 |
|
3 | | -## Docker environment |
| 3 | +## Entorno de Docker |
4 | 4 |
|
5 | | -This project needs a variety of requirements and it's highly recommended to set up a development environment through [Docker](https://www.docker.com/). |
| 5 | +Este proyecto tiene requisitos variados que hacen altamente recomendable configurar un entorno de desarrollo usando [Docker Compose](https://docs.docker.com/compose/). |
6 | 6 |
|
7 | | -1. Clone this repository. |
8 | | -2. Launch containers (building if proceed): |
| 7 | +1. Clona este repositorio. |
| 8 | +2. Inicia los contenedores: |
9 | 9 | ```console |
10 | | - $ docker-compose up # leave this running and open new tab |
| 10 | + $ docker-compose up # Deja esto ejecutando y abre una nueva pestaña |
11 | 11 | ``` |
12 | | -3. Run the database migrations: |
| 12 | +3. Ejecuta las migraciones de la base de datos: |
13 | 13 | ```console |
14 | 14 | $ docker-compose exec web ./manage.py migrate |
15 | 15 | ``` |
16 | | -4. Add initial test data to the DB (You will need this to test the web app): |
| 16 | +4. Añade datos iniciales de pruebas a la base datos (necesitarás esto para testear la app): |
17 | 17 | ```console |
18 | 18 | $ docker-compose exec web ./manage.py dbload |
19 | 19 | ``` |
20 | 20 |
|
21 | 21 | --- |
22 | 22 |
|
23 | | -> Instead of 3) and 4) you can load a (production) database dump using: |
| 23 | +> Si dispones de un volcado de la base de datos de pruebas o producción, puedes cargarlo así, en sustitución de los pasos 3 y 4: |
24 | 24 |
|
25 | 25 | ```console |
26 | 26 | $ docker-compose exec -T database /bin/bash -c \ |
27 | 27 | 'PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -d $POSTGRES_DB' < /path/to/db_dump.sql |
28 | 28 | ``` |
29 | 29 |
|
30 | | -> If you want to reproduce this last step afterwards, first be sure to remove the database volume with: `docker volume rm pycan-web_database-data`. |
| 30 | +> Para reproducir este último paso más adelante, asegúrate primero de borrar el volumen de la base datos con: `docker volume rm pycan-web_database-data`. |
31 | 31 |
|
32 | 32 | --- |
33 | 33 |
|
34 | | -5. Create a default superuser: |
| 34 | +5. Crea un superusuario: |
35 | 35 | ```console |
36 | 36 | $ docker-compose exec web ./manage.py create_default_admin # admin | admin |
37 | 37 | ``` |
38 | 38 |
|
39 | | -That's it, now visit http://localhost:8000/ |
| 39 | +Eso es todo, ahora puedes visitar http://localhost:8000/ |
40 | 40 |
|
41 | | -> Note that both the database and the web app bind their ports to the host. If you have port conflicts, you can export the environment variables `PYCAN_DB_PORT` and, `PYCAN_APP_PORT` to the desired ports in the host for, respectively, the database and the app, before running `docker-compose up`. |
| 41 | +> Nótese que tanto la base de datos y la app web enlazan sus puertos de los contenedores a los del sistema host. Si tienes conflictos con puertos, puedes exportar las variables de entorno `PYCAN_DB_PORT` y, `PYCAN_APP_PORT` con los puertos elegidos en el sistema host para, respectivamente, la base de datos y la app, antes de ejecutar `docker-compose up`. |
42 | 42 |
|
43 | | -### Administrative interface |
| 43 | +### Interfaz Administrativa |
44 | 44 |
|
45 | | -You can access the Django administrative interface visiting http://localhost:8000/admin using credentials: `username: admin` | `password: admin` |
| 45 | +Puedes acceder a la interfaz administrativa de Django yendo a https://docs.docker.com/compose/ y usando las credenciales `admin` / `admin`. |
46 | 46 |
|
47 | | -### Media |
| 47 | +### Multimedia |
48 | 48 |
|
49 | | -If you have a bunch of (production) files for media, you can leave them in the folder `$PROJECT/media`. A docker volume is set up to collect them from there. |
| 49 | +Si dispones de ficheros multimedia para testing o como copias de producción, puedes ponerlos en el directorio `$PROJECT/media`. Hay un volumen de Docker Compose configurado para cargarlos desde ahí. |
50 | 50 |
|
51 | | -## Code style |
| 51 | +## Estilo de código |
52 | 52 |
|
53 | | -Some hints should be followed in order to homogenize **Python** code style: |
| 53 | +Intentamos homogeneizar nuestro estilo de código en Python: |
54 | 54 |
|
55 | | -- Indenting with 4 spaces. |
56 | | -- Max line length: 79 chars. |
57 | | -- Imports ordering like in [PEP8](https://www.python.org/dev/peps/pep-0008/#imports). |
58 | | -- Python linter: [Flake8](https://flake8.pycqa.org/en/latest/) |
59 | | -- Python autoformatter: [Black](https://github.com/psf/black) |
| 55 | +- Indentado con 4 espacios. |
| 56 | +- Máximo ancho de línea: 79 caracteres. |
| 57 | +- Orden de imports como indica [PEP8](https://www.python.org/dev/peps/pep-0008/#imports). |
| 58 | +- Linter de Python: [Flake8](https://flake8.pycqa.org/en/latest/) |
| 59 | +- Autoformateador de Python: [Black](https://github.com/psf/black) |
60 | 60 |
|
61 | | -## VSCode over Docker |
| 61 | +## VSCode y Docker |
62 | 62 |
|
63 | | -One of the multiple options for editing code is [Visual Studio Code](https://code.visualstudio.com/). A nice feature is to link a remote container and configure the IDE installing the required tools on it. |
| 63 | +Si usas [Visual Studio Code](https://code.visualstudio.com/), puedes enlazar un contenedor remoto y configurar el IDE para usarlo. |
64 | 64 |
|
65 | | -In order to use the Docker development environment in VSCode you have to install the extension [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). |
| 65 | +Para usar el entorno de desarrollo Docker Compose en VSCode, instala la extensión [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). |
66 | 66 |
|
67 | | -The folder `.devcontainer` already contains the necessary files to enable the Docker "remote" container. Just follow [these instructions](https://code.visualstudio.com/docs/remote/containers) to enable it. |
| 67 | +El directorio `.devcontainer` contiene la configuración necesaria para dar soporte a esta integración. Sigue [estas instrucciones](https://code.visualstudio.com/docs/remote/containers) para habilitarlo. |
68 | 68 |
|
69 | | -> A good tutorial for setting up VSCode over Docker was broadcasted by Python Malaga. [Check it out](https://www.youtube.com/watch?v=mxpq0ntJ8T8)! |
| 69 | +> Python Malaga tiene un buen [tutorial de cómo configurar VSCode usando Docker](https://www.youtube.com/watch?v=mxpq0ntJ8T8). |
0 commit comments