Skip to content

Commit 02c9388

Browse files
Improvements for development (#286)
1 parent 11daf63 commit 02c9388

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

.dockerignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Ignore common Python files and directories
2+
*.pyc
3+
__pycache__/
4+
*.pyo
5+
*.pyd
6+
7+
# Ignore development and testing files
8+
*.env
9+
*.log
10+
*.sqlite3
11+
12+
# Ignore virtual environment files
13+
venv/
14+
.env
15+
16+
# vscode & codespaces
17+
.vscode/*
18+
!.vscode/settings.json
19+
!.vscode/tasks.json
20+
!.vscode/launch.json
21+
!.vscode/extensions.json
22+
*.code-workspace

Dockerfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use the official Python image as the base image
2+
FROM python:3.12-alpine
3+
4+
# Install MySQL and PostgreSQL client libraries
5+
RUN apk update && apk add --no-cache \
6+
mariadb-connector-c-dev \
7+
postgresql-dev python3-dev musl-dev
8+
9+
# Install Tox
10+
RUN pip install tox
11+
RUN tox -e dev
12+
13+
# Set the working directory
14+
WORKDIR /app
15+
16+
# Copy the project files to the working directory
17+
COPY . /app
18+
19+
# Set the entrypoint command
20+
CMD ["tox"]

README.rst

+14
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,27 @@ Create development virtualenv (you need to have tox installed in your base syste
122122
tox -e dev
123123
source .tox/dev/bin/activate
124124

125+
To run the test project, with the folder of the project as the current directory, run::
126+
127+
export PYTHONPATH="${PYTHONPATH}:/app/src"
128+
docker run -d postgres -p 5432:5432
129+
130+
125131
Then run the full import::
126132

127133
test_project/manage.py migrate
128134
test_project/manage.py cities_light
129135

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

138+
For example to change the database engine, you can run::
139+
140+
export DB_ENGINE=postgresql
141+
export DB_HOST=192.168.0.118
142+
export DB_NAME=app
143+
export DB_USER=postgres
144+
export DB_PORT=5432
145+
132146
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.
133147

134148
Running the full test suite::

docker-compose.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3.9'
2+
services:
3+
db:
4+
image: postgres
5+
environment:
6+
POSTGRES_PASSWORD: example
7+
app:
8+
build: .
9+
volumes:
10+
- .:/app
11+
working_dir: /app
12+
links:
13+
- db

0 commit comments

Comments
 (0)