Skip to content

Commit c23484f

Browse files
committed
Update to include test-app for test driven development
1 parent 4e8d9aa commit c23484f

File tree

8 files changed

+79
-4
lines changed

8 files changed

+79
-4
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"source=${localWorkspaceFolder}/frontend,target=/app/frontend,type=bind"
1313
],
1414
"forwardPorts": [
15-
8000, 3000, 5432, 6379, 9092, 80, 9090, 3001, 8080, 8001
15+
8000, 3000, 5432, 6379, 9092, 80, 9090, 3001, 8080, 8001, 8050
1616
],
1717
"runServices": [
1818
"django",
@@ -25,7 +25,8 @@
2525
"prometheus",
2626
"osm-tile-server",
2727
"pgadmin",
28-
"redisinsight"
28+
"redisinsight",
29+
"test-app"
2930
],
3031
"customizations": {
3132
"vscode": {

.devcontainer/docker-compose.debug.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ services:
2626
networks:
2727
- common_network
2828

29+
test-app: #To run this service, it needs to be noted in devcontainer.json
30+
build:
31+
context: ./.devcontainer/test-app
32+
dockerfile: dockerfile.simulator
33+
container_name: Dummydatacreate
34+
volumes:
35+
- ./.devcontainer/test-app:/test-app # Maps the local directory to /app in the container
36+
env_file:
37+
- ./.env
38+
environment:
39+
#- DATABASE_URL=postgresql+psycopg2://postgres:true4@postgis:5432/gist4
40+
DATABASE_URL: "postgresql+psycopg2://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
41+
depends_on:
42+
- postgres
43+
ports:
44+
- "8050:8050" # Adjust according to your application needs
45+
#command: ["sleep", "infinity"] # Keeps the container running after building
46+
networks:
47+
- common_network
48+
2949
networks:
3050
common_network:
3151
driver: bridge
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use an official Python runtime as a parent image
2+
FROM python:3.11-slim-buster
3+
4+
# Set environment variables
5+
ENV PYTHONDONTWRITEBYTECODE 1
6+
ENV PYTHONUNBUFFERED 1
7+
8+
# Set the working directory in the container
9+
WORKDIR /test-app
10+
11+
# Install system dependencies
12+
RUN apt-get update && apt-get install -y \
13+
build-essential \
14+
libpq-dev \
15+
gdal-bin \
16+
libgdal-dev \
17+
postgresql-client \
18+
&& apt-get clean \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# Copy the requirements file and install Python dependencies
22+
COPY reqtest.txt .
23+
RUN pip install --no-cache-dir -r reqtest.txt
24+
25+
# Do not specify CMD, as we'll run commands interactively during development
26+
# Default command to keep the container running
27+
CMD ["sleep", "infinity"]

.devcontainer/test-app/reqtest.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
certifi==2024.7.4
2+
et-xmlfile==1.1.0
3+
GeoAlchemy2==0.15.2
4+
geopandas==1.0.1
5+
greenlet==3.0.3
6+
numpy==2.0.1
7+
openpyxl==3.1.5
8+
packaging==24.1
9+
pandas==2.2.2
10+
psycopg2==2.9.9
11+
pyogrio==0.9.0
12+
pyproj==3.6.1
13+
python-dateutil==2.9.0.post0
14+
pytz==2024.1
15+
shapely==2.0.5
16+
six==1.16.0
17+
SQLAlchemy==2.0.32
18+
typing_extensions==4.12.2
19+
tzdata==2024.1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
.env
22
*.bak
3+
*.xlsx
4+
*.xls
5+

backend/core/core/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999

100100
# NAME,USER, PASSWORD, HOST and PORT are from environment variables defined in Django container in docker-compose.yml. If they do not work, default ones are given.
101101
# os.environ.get( environmental_varible, default value)
102+
# HOST specifies the IP address via actual IP notation or service notation (services get IP address allocated by docker compose)
102103
DATABASES = {
103104
'default': {
104105
'ENGINE': 'django.contrib.gis.db.backends.postgis',

backend/core/p1backend/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class Contact(models.Model):
5050
address = models.CharField(max_length=100)
5151
gps_location = models.PointField()
5252
email = models.CharField(max_length=100)
53+
54+
class Meta:
55+
db_table = "cosellwkt"
56+
managed = False
5357

5458
def __str__(self):
5559
return self.name

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ services:
1818
- POSTGRES_DB=${POSTGRES_DB}
1919
- POSTGRES_USER=${POSTGRES_USER}
2020
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
21-
- POSTGRES_HOST=postgres
22-
- POSTGRES_PORT=5432
21+
- POSTGRES_HOST=${POSTGRES_HOST}
22+
- POSTGRES_PORT=${POSTGRES_PORT}
2323
- REDIS_HOST=redis
2424
- KAFKA_BROKER=kafka:9092
2525
networks:

0 commit comments

Comments
 (0)