Skip to content

Commit

Permalink
reconfigure items
Browse files Browse the repository at this point in the history
  • Loading branch information
BryonLewis committed Feb 19, 2024
1 parent f489ce1 commit ebeaa0e
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 21 deletions.
18 changes: 17 additions & 1 deletion bats_ai/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,23 @@ class TestingConfiguration(BatsAiMixin, TestingBaseConfiguration):


class ProductionConfiguration(BatsAiMixin, ProductionBaseConfiguration):
pass
SECRET_KEY = 'secretkey' # Dummy value for local development configuration

DEFAULT_FILE_STORAGE = 'minio_storage.storage.MinioMediaStorage'
MINIO_STORAGE_ENDPOINT = values.Value(
'minio:9000',
)
MINIO_STORAGE_USE_HTTPS = values.BooleanValue(False)
MINIO_STORAGE_ACCESS_KEY = values.SecretValue()
MINIO_STORAGE_SECRET_KEY = values.SecretValue()
MINIO_STORAGE_MEDIA_BUCKET_NAME = values.Value(
environ_name='STORAGE_BUCKET_NAME',
environ_required=True,
)
MINIO_STORAGE_AUTO_CREATE_MEDIA_BUCKET = True
MINIO_STORAGE_AUTO_CREATE_MEDIA_POLICY = 'READ_WRITE'
MINIO_STORAGE_MEDIA_USE_PRESIGNED = True
MINIO_STORAGE_MEDIA_URL = 'http://127.0.0.1:9000/django-storage'


class HerokuProductionConfiguration(BatsAiMixin, HerokuProductionBaseConfiguration):
Expand Down
4 changes: 2 additions & 2 deletions client/.env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VUE_APP_API_ROOT=http://localhost:8000/api/v1
VUE_APP_OAUTH_API_ROOT=http://localhost:8000/oauth/
VUE_APP_API_ROOT=http://localhost/api/v1
VUE_APP_OAUTH_API_ROOT=http://localhost/oauth/
VUE_APP_OAUTH_CLIENT_ID=HSJWFZ2cIpWQOvNyCXyStV9hiOd7DfWeBOCzo4pP
11 changes: 11 additions & 0 deletions dev/.env.prod.docker-compose
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DJANGO_CONFIGURATION=DProductionConfiguration
DJANGO_DATABASE_NAME=django
DJANGO_DATABASE_PASSWORD=postgres
DJANGO_DATABASE_URL=postgres://postgres:postgres@postgres:5432/django
DJANGO_CELERY_BROKER_URL=amqp://rabbitmq:5672/
DJANGO_MINIO_STORAGE_ENDPOINT=minio:9000
DJANGO_MINIO_STORAGE_ACCESS_KEY=minioAccessKey
DJANGO_MINIO_STORAGE_SECRET_KEY=minioSecretKey
DJANGO_STORAGE_BUCKET_NAME=django-storage
DJANGO_MINIO_STORAGE_ENDPOINT=minio:9000
DJANGO_CORS_ORIGIN_WHITELIST=http://localhost:3000
17 changes: 12 additions & 5 deletions dev/client.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Use official Node.js image as the base image
# Use official Node.js image as the base image for building Vue.js app
FROM node:16 as build-stage

# Set working directory
Expand All @@ -16,14 +16,21 @@ COPY client .
# Build the Vue.js application
RUN npm run build

# Production stage
# Use NGINX as the final base image
FROM nginx:alpine

# Copy built app from build stage to nginx
# Remove default NGINX website
RUN rm -rf /usr/share/nginx/html/*

# Copy built Vue.js app to NGINX HTML directory
COPY --from=build-stage /app/dist /usr/share/nginx/html

# Expose port 80 to the outer world
RUN ls
# Copy custom NGINX configuration
COPY nginx/nginx.conf /etc/nginx/nginx.conf

# Expose port 80
EXPOSE 80

# Command to run nginx
# Start NGINX
CMD ["nginx", "-g", "daemon off;"]
74 changes: 73 additions & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
# Log printing via Rich is enhanced by a TTY
tty: true
env_file: ./dev/.env.docker-compose
networks:
- django-nginx
volumes:
- .:/opt/django-project
ports:
Expand Down Expand Up @@ -44,10 +46,80 @@ services:
build:
context: .
dockerfile: ./dev/client.Dockerfile
networks:
- django-nginx
ports:
- 80:80
depends_on:
- django

postgres:
image: postgis/postgis:latest
environment:
- POSTGRES_DB=${DJANGO_DATABASE_NAME:-django}
- POSTGRES_PASSWORD=${DJANGO_MINIO_STORAGE_SECRET_KEY:-postgres}
networks:
- django-nginx
ports:
- ${DOCKER_POSTGRES_PORT-5432}:5432
volumes:
- postgres:/var/lib/postgresql/data

rabbitmq:
image: rabbitmq:management
networks:
- django-nginx
ports:
- ${DOCKER_RABBITMQ_PORT-5672}:5672
- ${DOCKER_RABBITMQ_CONSOLE_PORT-15672}:15672
volumes:
- rabbitmq:/var/lib/rabbitmq/mnesia

minio:
image: minio/minio:latest
# When run with a TTY, minio prints credentials on startup
tty: true
command: ["server", "/data", "--console-address", ":${DOCKER_MINIO_CONSOLE_PORT-9001}"]
environment:
- MINIO_ROOT_USER=${DJANGO_MINIO_STORAGE_ACCESS_KEY:-minioAccessKey}
- MINIO_ROOT_PASSWORD=${DJANGO_DATABASE_PASSWORD:-minioSecretKey}
networks:
- django-nginx
ports:
- ${DOCKER_MINIO_PORT-9000}:9000
- ${DOCKER_MINIO_CONSOLE_PORT-9001}:9001
volumes:
- minio:/data

flower:
build:
context: .
dockerfile: ./dev/django.Dockerfile
command: [
"celery",
"--app", "bats_ai.celery",
"flower"
]
tty: false
env_file: ./dev/.env.docker-compose
volumes:
- .:/opt/django-project
networks:
- django-nginx
ports:
- ${DOCKER_FLOWER_PORT-5555}:5555
depends_on:
- postgres
- rabbitmq
- minio
- celery

volumes:
postgres:
sourcedb:
minio:
rabbitmq:

networks:
backend:
django-nginx:
driver: bridge
52 changes: 40 additions & 12 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,61 @@ events {
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

upstream django {
server django:8000;
}
upstream vue_app {
server vue_app:80;
}
client_max_body_size 100m;

server {
listen 80;
server_name localhost;


# Serve Vue.js static files
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
# Proxy API requests to Django
location /api {
proxy_pass http://django;
proxy_pass http://django:8000/api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
location /oauth {
proxy_pass http://django:8000/oauth;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
location /static {
proxy_pass http://django:8000/static;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}

location / {
proxy_pass http://vue_app;
location /admin {
proxy_pass http://django:8000/admin;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
try_files $uri $uri/ /index.html;
proxy_redirect off;
}
location /accounts {
proxy_pass http://django:8000/accounts;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}


}
}

0 comments on commit ebeaa0e

Please sign in to comment.