Skip to content

Commit

Permalink
Improvements for development
Browse files Browse the repository at this point in the history
  • Loading branch information
marianoeramirez committed Jan 8, 2024
1 parent 11daf63 commit c2cf589
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Ignore common Python files and directories
*.pyc
__pycache__/
*.pyo
*.pyd

# Ignore development and testing files
*.env
*.log
*.sqlite3

# Ignore virtual environment files
venv/
.env

# vscode & codespaces
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Python image as the base image
FROM python:3.12-alpine

# Install MySQL and PostgreSQL client libraries
RUN apk update && apk add --no-cache \
mariadb-connector-c-dev \
postgresql-dev python3-dev musl-dev

# Install Tox
RUN pip install tox
RUN tox -e dev

# Set the working directory
WORKDIR /app

# Copy the project files to the working directory
COPY . /app

# Set the entrypoint command
CMD ["tox"]
14 changes: 14 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,27 @@ Create development virtualenv (you need to have tox installed in your base syste
tox -e dev
source .tox/dev/bin/activate

To run the test project, with the folder of the project as the current directory, run::
export PYTHONPATH="${PYTHONPATH}:/app/src"
docker run -d postgres -p 5432:5432


Then run the full import::

test_project/manage.py migrate
test_project/manage.py cities_light

There are several environment variables which affect project settings (like DB_ENGINE and CI), you can find them all in test_project/settings.py.

For example to change the database engine, you can run::

export DB_ENGINE=postgresql
export DB_HOST=192.168.0.118
export DB_NAME=app
export DB_USER=postgres
export DB_PORT=5432

To run the test suite you need to have postgresql or mysql installed with passwordless login, or just use sqlite. Otherwise the tests which try to create/drop database will fail.

Running the full test suite::
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.9'
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: example
app:
build: .
volumes:
- .:/app
working_dir: /app
links:
- db

0 comments on commit c2cf589

Please sign in to comment.