Skip to content

Commit 9ee8a9d

Browse files
committed
fixes stuff
1 parent 7038e0b commit 9ee8a9d

6 files changed

Lines changed: 22 additions & 44 deletions

File tree

.env.production.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ APP_NAME=DjangoAPI
99
API_SECRET_KEY= CHANGE THIS TO A RANDOM STRING
1010
API_ALLOWED_HOSTS=".localhost 127.0.0.1 [::1]"
1111

12-
POSTGRES_HOST=localhost
12+
POSTGRES_HOST=db
1313
POSTGRES_NAME=postgres
1414
POSTGRES_USER=postgres
1515
POSTGRES_PASSWORD=password

docker-compose.prod.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,28 @@ services:
1212
retries: 5
1313

1414
server:
15-
image: ghcr.io/codersforcauses/robodrone-prod-server:latest
15+
build:
16+
context: .
17+
dockerfile: docker/server/Dockerfile
1618
container_name: robodrone_server
1719
restart: unless-stopped
1820
env_file: ./.env.prod
1921
ports:
20-
- 8000:8000
22+
- 8081:8081
2123
entrypoint: /entrypoint.sh
2224
volumes:
2325
- ./opt/accesslogs/:/var/log/accesslogs/
24-
- ./opt/static_files:/opt/static_files
26+
- ./opt/static_files:/app/static_files
2527
environment:
2628
- DJANGO_SETTINGS_MODULE=api.settings
2729
depends_on:
2830
- db
2931

3032
client:
31-
image: ghcr.io/codersforcauses/robodrone-prod-client:latest
33+
# image: ghcr.io/codersforcauses/robodrone-prod-client:latest
34+
build:
35+
context: .
36+
dockerfile: docker/client/Dockerfile
3237
container_name: robodrone_client
3338
restart: unless-stopped
3439
env_file: ./.env.prod

docker/client/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ RUN npm install
1414
# Copy Application code into a directory called `app`
1515
COPY ./client /app
1616

17+
RUN npm run build
18+
1719
# ========================================
1820
# ---- Executed at Container Runtime ----
1921
# ========================================
2022

2123
# CMD commands get executed at container runtime!
2224
RUN chmod +x /entrypoint.sh
23-
CMD ["/entrypoint.sh"]
24-
25-
# TODO: Production
25+
CMD ["/entrypoint.sh"]

docker/client/entrypoint.sh

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,7 @@
11
#!/bin/bash
22

33
echo "${APP_NAME^^} - NextJS CONTAINER STARTING..."
4-
echo $APP_NAME
54

6-
# Display Docker Image / CI / Release details
7-
echo "Image Build Date/Time: " "$(cat /app/build_timestamp.txt)" "UTC"
8-
9-
echo "-----------------------------------------------------------"
10-
echo "APP_ENV: ${APP_ENV}"
11-
12-
# # ====================================================================================
13-
# # Debug / Sanity check info
14-
# # ====================================================================================
15-
# echo " "
16-
# echo "======= Current Dir / Files (Debug) ============================================================================="
17-
# pwd
18-
# ls -al
19-
20-
# echo " "
21-
# echo "======= Env Vars (Debug) ========================================================================================"
22-
# if [ "${APP_ENV^^}" != "PRODUCTION" ]; then
23-
# # Only print environment vars in non-prod environments to prevent sensitive variables being sent to logging system
24-
# printenv
25-
# fi
26-
27-
# echo " "
28-
# echo "======= Linux version (Debug) ==================================================================================="
29-
# cat /etc/os-release
30-
31-
# echo " "
32-
# echo "======= Node Path & Version (Debug) ==========================================================================="
33-
# node -v
345

356
# Check for required env vars, exit as failure if missing these critical env vars.
367
if [[ -z "${APP_ENV}" ]]; then
@@ -55,4 +26,6 @@ if [ "${APP_ENV^^}" = "DEVELOPMENT" ]; then
5526
echo "======= Starting inbuilt nextjs webserver ==================================================================="
5627
npm run dev
5728
exit
58-
fi
29+
fi
30+
31+
npm run start

docker/nginx/custom.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ http {
1313

1414
# upstream to the server container
1515
upstream backend {
16-
server server:8000; #name of container:port exposed
16+
server server:8081; #name of container:port exposed
1717
}
1818

1919
# upstream to the server container
@@ -41,7 +41,7 @@ http {
4141
}
4242
# serve django static files
4343
location /static/ {
44-
alias /server/staticfiles/;
44+
alias /opt/static_files/;
4545
}
4646
# proxy to client
4747
location / {

docker/server/entrypoint.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ if [ "${APP_ENV^^}" = "DEVELOPMENT" ]; then
3333

3434
# Run developments
3535
printf "\n" && echo "Starting inbuilt django webserver"
36-
echo "Running: python manage.py runserver 0.0.0.0:8000"
37-
python manage.py runserver 0.0.0.0:8000
36+
echo "Running: python manage.py runserver 0.0.0.0:8081"
37+
python manage.py runserver 0.0.0.0:8081
3838
exit
3939
fi
4040

@@ -45,6 +45,6 @@ if [ "${APP_ENV^^}" = "PRODUCTION" ]; then
4545

4646
# Run Gunicorn / Django
4747
printf "\n" && echo " Running Gunicorn / Django"
48-
echo "Running: gunicorn api.wsgi -b 0.0.0.0:8000 --workers=6 --keep-alive 20 --log-file=- --log-level debug --access-logfile=/var/log/accesslogs/gunicorn --capture-output --timeout 50"
49-
gunicorn api.wsgi -b 0.0.0.0:8000 --workers=6 --keep-alive 20 --log-file=- --log-level debug --access-logfile=/var/log/accesslogs/gunicorn --capture-output --timeout 50
48+
echo "Running: gunicorn api.wsgi -b 0.0.0.0:8081 --workers=6 --keep-alive 20 --log-file=- --log-level debug --access-logfile=/var/log/accesslogs/gunicorn --capture-output --timeout 50"
49+
gunicorn api.wsgi -b 0.0.0.0:8081 --workers=6 --keep-alive 20 --log-file=- --log-level debug --access-logfile=/var/log/accesslogs/gunicorn --capture-output --timeout 50
5050
fi

0 commit comments

Comments
 (0)