Skip to content

Commit e00ad5e

Browse files
Merge pull request #6 from Kalgoc/main
Actualización develop
2 parents 2da3dc5 + 90abcd3 commit e00ad5e

File tree

8 files changed

+38
-41
lines changed

8 files changed

+38
-41
lines changed

.github/workflows/deploy.yml

-21
This file was deleted.

.github/workflows/pytest.yml

+2
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ jobs:
3131
pip install pipenv
3232
pipenv install --system --dev
3333
- uses: pavelzw/pytest-action@v2
34+
env:
35+
SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
3436
with:
3537
emoji: false

Dev.Dockerfile

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ FROM python:3.11-alpine
22

33
WORKDIR /app
44

5-
# Instalar paquetes necesarios para construir psycopg2 y otras dependencias, y netcat para comprobar la conexión de la base de datos
65
RUN apk add --no-cache gcc musl-dev python3-dev libffi-dev postgresql-dev
76
RUN apk add --no-cache netcat-openbsd
87

9-
# Install pipenv
108
RUN pip install --upgrade pip
119
RUN pip install pipenv
1210

13-
# Install application dependencies
1411
COPY Pipfile Pipfile.lock /app/
15-
# We use the --system flag so packages are installed into the system python
16-
# and not into a virtualenv. Docker containers don't need virtual environments.
12+
1713
RUN pipenv install --system --dev
1814

1915
COPY . /app/

Dockerfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM python:3.11-alpine
2+
3+
WORKDIR /app
4+
5+
RUN apk add --no-cache gcc musl-dev libffi-dev postgresql-dev bash
6+
7+
RUN pip install --upgrade pip
8+
RUN pip install pipenv
9+
10+
COPY Pipfile Pipfile.lock /app/
11+
12+
RUN pipenv install --system --deploy
13+
14+
COPY . /app/
15+
COPY docker-entrypoint.sh /app/
16+
RUN chmod +x /app/docker-entrypoint.sh
17+
18+
EXPOSE 8000
19+
20+
ENTRYPOINT [ "./docker-entrypoint.sh" ]

docker-compose.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ services:
44
db:
55
container_name: db
66
image: postgres:latest
7-
environment:
8-
- POSTGRES_USER=postgres
9-
- POSTGRES_PASSWORD=postgres
107
volumes:
118
- postgres_data:/var/lib/postgresql/data
129
ports:
@@ -17,7 +14,7 @@ services:
1714
web:
1815
build:
1916
context: .
20-
dockerfile: Dev.Dockerfile
17+
dockerfile: Dockerfile
2118
container_name: web
2219
volumes:
2320
- .:/app
@@ -28,6 +25,13 @@ services:
2825
- db
2926
networks:
3027
- app_network
28+
environment:
29+
POSTGRES_DB: ${DB_NAME}
30+
POSTGRES_USER: ${DB_USER}
31+
POSTGRES_PASSWORD: ${DB_PASSWORD}
32+
POSTGRES_PORT: ${DB_PORT}
33+
POSTGRES_HOST: ${DB_HOST}
34+
DJANGO_SETTINGS_MODULE: piggywallet.settings.prod
3135

3236
networks:
3337
app_network:

manage.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
def main():
88
"""Run administrative tasks."""
9-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "piggywallet.settings.dev")
10-
# os.environ.setdefault("DJANGO_CONFIGURATION", "piggywallet.settings.prod")
9+
os.environ.setdefault("DJANGO_CONFIGURATION", "piggywallet.settings")
1110
try:
1211
from django.core.management import execute_from_command_line
1312
except ImportError as exc:

piggywallet/settings/base.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
"""
1212

1313
from pathlib import Path
14+
import os
15+
from dotenv import load_dotenv
1416

17+
load_dotenv()
1518
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1619
BASE_DIR = Path(__file__).resolve().parent.parent
1720

@@ -20,13 +23,7 @@
2023
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
2124

2225
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = "django-insecure-epw6&76ijtauz9tb6p+a%-&gdfwtuao3p6@p9v=230r_0zd2l+"
24-
25-
# SECURITY WARNING: don't run with debug turned on in production!
26-
DEBUG = True
27-
28-
ALLOWED_HOSTS = []
29-
26+
SECRET_KEY = os.getenv("SECRET_KEY")
3027

3128
# Application definition
3229

piggywallet/settings/prod.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import os
33
from dotenv import load_dotenv
44

5-
# DEBUG = False
6-
# ALLOWED_HOSTS = ['mydomain.com']
5+
DEBUG = False
6+
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "").split(",")
77

88
load_dotenv()
99
DATABASES = {

0 commit comments

Comments
 (0)