Merge pull request 'updates-for-docker' (#1) from updates-for-docker into main
Reviewed-on: softwareshinobi/card-players-unite-server#1
This commit was merged in pull request #1.
This commit is contained in:
51
Dockerfile
51
Dockerfile
@@ -1,47 +1,20 @@
|
||||
FROM python:3.8
|
||||
|
||||
# base image
|
||||
|
||||
FROM python:3.8
|
||||
|
||||
# setup environment variable
|
||||
|
||||
ENV DockerHOME=/home/app/webapp
|
||||
|
||||
# set work directory
|
||||
|
||||
RUN mkdir -p $DockerHOME
|
||||
|
||||
# where your code lives
|
||||
|
||||
WORKDIR $DockerHOME
|
||||
|
||||
# set environment variables
|
||||
|
||||
ENV DockerHOME=/home/app/webapp
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
RUN mkdir -p $DockerHOME
|
||||
WORKDIR $DockerHOME
|
||||
|
||||
# install dependencies
|
||||
|
||||
RUN pip install --upgrade pip
|
||||
|
||||
# copy whole project to your docker home directory.
|
||||
#RUN pip install --upgrade pip
|
||||
RUN pip install "pip<24.1"
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
# run this command to install all dependencies
|
||||
EXPOSE 8000
|
||||
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
RUN python3 manage.py makemigrations
|
||||
|
||||
RUN python3 manage.py migrate
|
||||
|
||||
|
||||
# port where the Django app runs
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
# start server
|
||||
|
||||
CMD python manage.py runserver 0.0.0.0:8000
|
||||
# Use a shell script or combined command for runtime tasks
|
||||
CMD python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000
|
||||
|
||||
@@ -102,16 +102,8 @@ WSGI_APPLICATION = 'application.wsgi.application'
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'maverickdb',
|
||||
'USER':'maverickdb',
|
||||
'PASSWORD':'maverickdb',
|
||||
'HOST':'localhost',
|
||||
'PORT':'5432'
|
||||
}
|
||||
}
|
||||
|
||||
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'maverickdb', 'USER': 'maverickdb', 'PASSWORD': 'maverickdb', 'HOST': 'card-players-unite-postgres', 'PORT': '5432', } }
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
||||
|
||||
53
compose.bash
53
compose.bash
@@ -1,52 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
##
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
set -x
|
||||
|
||||
##
|
||||
|
||||
reset
|
||||
|
||||
clear
|
||||
|
||||
##
|
||||
|
||||
# 1. Shut down existing containers
|
||||
docker compose down --remove-orphans
|
||||
|
||||
docker compose up -d
|
||||
# 2. Build and start containers in the background
|
||||
# The Dockerfile's CMD will handle migrations and runserver automatically.
|
||||
docker compose up -d --build
|
||||
|
||||
sleep 8
|
||||
|
||||
########
|
||||
|
||||
###docker-compose -f postgres.yaml pull
|
||||
|
||||
#python3 manage.py dumpdata
|
||||
## This will IRREVERSIBLY DESTROY all data currently in the "maverickdb" database, and return each table to an empty state.
|
||||
|
||||
|
||||
|
||||
### python3 manage.py flush
|
||||
|
||||
### python3 manage.py sqlflush
|
||||
|
||||
#python3 manage.py sqlmigrate
|
||||
|
||||
##python3 manage.py sqlsequencereset
|
||||
|
||||
#python3 manage.py generateschema
|
||||
|
||||
|
||||
|
||||
python3 manage.py makemigrations
|
||||
|
||||
python3 manage.py migrate
|
||||
|
||||
#python3 manage.py squashmigrations bikes
|
||||
|
||||
#python3 manage.py optimizemigration
|
||||
|
||||
python3 manage.py runserver 0.0.0.0:8888
|
||||
# 3. (Optional) Check the logs to ensure the migrations finished successfully
|
||||
docker compose logs -f
|
||||
|
||||
17
compose.yaml
17
compose.yaml
@@ -1,6 +1,19 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
# The Django Web Application
|
||||
web:
|
||||
build: .
|
||||
container_name: card-players-unite-web
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- .:/home/app/webapp
|
||||
environment:
|
||||
- POSTGRES_DB=maverickdb
|
||||
- POSTGRES_USER=maverickdb
|
||||
- POSTGRES_PASSWORD=maverickdb
|
||||
- POSTGRES_HOST=card-players-unite-postgres
|
||||
depends_on:
|
||||
- card-players-unite-postgres
|
||||
|
||||
card-players-unite-postgres:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user