Created
June 28, 2020 05:56
-
-
Save somangshu/1d591478ea4571e701daf3afde7b259f to your computer and use it in GitHub Desktop.
Django Docker Deployment on AWS ECS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.7-buster | |
# install nginx | |
RUN apt-get update && apt-get install nginx vim -y --no-install-recommends | |
COPY nginx.default /etc/nginx/sites-available/default | |
RUN ln -sf /dev/stdout /var/log/nginx/access.log \ | |
&& ln -sf /dev/stderr /var/log/nginx/error.log | |
# copy source and install dependencies | |
RUN mkdir -p /app | |
RUN mkdir -p /app/pip_cache | |
RUN mkdir -p /app/main | |
COPY requirements.txt start_server.sh /app/ | |
COPY main /app/main/ | |
WORKDIR /app | |
RUN pip install -r requirements.txt --cache-dir /app/pip_cache | |
RUN chown -R www-data:www-data /app | |
# start server | |
# exposing this port for nginx to listen | |
EXPOSE 8020 | |
STOPSIGNAL SIGTERM | |
CMD ["/app/start_server.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 8020; | |
server_name assetgaurd.com; | |
location / { | |
client_max_body_size 2M; | |
proxy_pass http://127.0.0.1:8010; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
location /static { | |
root /app/main; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
python main/manage.py migrate | |
(gunicorn assetgaurd.wsgi --user www-data --reload --bind 0.0.0.0:8010 --workers 3) & | |
nginx -g "daemon off;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ipcMode": null, | |
"executionRoleArn": null, | |
"containerDefinitions": [ | |
{ | |
"dnsSearchDomains": null, | |
"environmentFiles": null, | |
"logConfiguration": null, | |
"entryPoint": null, | |
"portMappings": [ | |
{ | |
"hostPort": 80, | |
"protocol": "tcp", | |
"containerPort": 8020 | |
} | |
], | |
"command": null, | |
"linuxParameters": null, | |
"cpu": 0, | |
"environment": [], | |
"resourceRequirements": null, | |
"ulimits": null, | |
"dnsServers": null, | |
"mountPoints": [], | |
"workingDirectory": "/app", | |
"secrets": null, | |
"dockerSecurityOptions": null, | |
"memory": 600, | |
"memoryReservation": null, | |
"volumesFrom": [], | |
"stopTimeout": null, | |
"image": "your-repo-image-url:latest", | |
"startTimeout": null, | |
"firelensConfiguration": null, | |
"dependsOn": null, | |
"disableNetworking": null, | |
"interactive": null, | |
"healthCheck": null, | |
"essential": true, | |
"links": null, | |
"hostname": null, | |
"extraHosts": null, | |
"pseudoTerminal": null, | |
"user": null, | |
"readonlyRootFilesystem": null, | |
"dockerLabels": null, | |
"systemControls": null, | |
"privileged": null, | |
"name": "finglance-web" | |
}, | |
], | |
"placementConstraints": [], | |
"memory": null, | |
"taskRoleArn": null, | |
"compatibilities": [ | |
"EC2" | |
], | |
"taskDefinitionArn": "arn:aws:ecs:us-east-1:497940987884:task-definition/assetgaurd:1", | |
"family": "assetgaurd-task", | |
"requiresAttributes": [ | |
{ | |
"targetId": null, | |
"targetType": null, | |
"value": null, | |
"name": "com.amazonaws.ecs.capability.ecr-auth" | |
}, | |
{ | |
"targetId": null, | |
"targetType": null, | |
"value": null, | |
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17" | |
} | |
], | |
"pidMode": null, | |
"requiresCompatibilities": [ | |
"EC2" | |
], | |
"networkMode": null, | |
"cpu": null, | |
"revision": 7, | |
"status": "ACTIVE", | |
"inferenceAccelerators": null, | |
"proxyConfiguration": null, | |
"volumes": [] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment