Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements for development process #286

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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