Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oser-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hamza Touizrat
oser-backend
Commits
12880493
Commit
12880493
authored
Mar 10, 2018
by
florimondmanca
Browse files
Options
Downloads
Patches
Plain Diff
add volume to persist data
parent
8e687a26
No related branches found
No related tags found
1 merge request
!1
Dockerize app and update TravisCI file
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Dockerfile
+12
-2
12 additions, 2 deletions
Dockerfile
docker-compose.yml
+6
-0
6 additions, 0 deletions
docker-compose.yml
nginx/nginx.conf
+14
-9
14 additions, 9 deletions
nginx/nginx.conf
start.sh
+0
-10
0 additions, 10 deletions
start.sh
with
32 additions
and
21 deletions
Dockerfile
+
12
−
2
View file @
12880493
from
python:3.6
EXPOSE
8000
ENV
PYTHONUNBUFFERED=0
ADD
. /oser-backend
WORKDIR
/oser-backend/oser_backend
# Debug only
RUN
ls
RUN
echo
"Content of oser-backend/ directory:"
;
ls
..
RUN
echo
"Content of oser_backend/ directory:"
;
ls
# Install dependencies
RUN
pip3
install
-r
../requirements.txt
RUN
pip3
install
gunicorn
# Collect static files
RUN
python3 manage.py collectstatic
--noinput
# Setup database
RUN
python3 manage.py makemigrations
RUN
python3 manage.py migrate
RUN
python3 manage.py initadmin
CMD
sh ../start.sh
This diff is collapsed.
Click to expand it.
docker-compose.yml
+
6
−
0
View file @
12880493
...
...
@@ -8,6 +8,8 @@ services:
container_name
:
django_01
expose
:
-
"
8000"
# port where the Django app runs
volumes
:
-
data:/oser-backend
restart
:
on-failure
# Nginx server
...
...
@@ -23,3 +25,7 @@ services:
depends_on
:
-
gunicorn
restart
:
on-failure
# create a volume to enable persisting data
volumes
:
data
:
This diff is collapsed.
Click to expand it.
nginx/nginx.conf
+
14
−
9
View file @
12880493
# Allows to write http://gunicorn to point to the Gunicorn server (see below)
upstream
gunicorn
{
ip_hash
;
server
gunicorn
:
8000
;
}
server
{
server_name
web
;
listen
8000
;
# Log files locations
access_log
/var/log/nginx/guni-access.log
;
error_log
/var/log/nginx/guni-error.log
info
;
location
/static/
{
# Serve static files collected by Django's collectstatic command
#
which are
located in the
/
static
/
folder
# Serve static files collected by Django's collectstatic command
,
# located in the static folder
.
autoindex
on
;
alias
/static/
;
}
location
/media/
{
# Serve user uploaded media, uploaded to the media folder.
autoindex
on
;
alias
/media/
;
}
location
/
{
# Pass requests to the Gunicorn server running the Django app
proxy_pass
http://gunicorn
;
proxy_pass
http://gunicorn
:8000
;
# Send full host in header (default is service name, i.e. gunicorn).
# Ensures that absolute URLs on Django app are accessible (e.g. in
# discoverable API).
proxy_set_header
Host
$http_host
;
proxy_set_header
X-Forwarded-For
$proxy_add_x_forwarded_for
;
}
}
This diff is collapsed.
Click to expand it.
start.sh
+
0
−
10
View file @
12880493
#!/usr/bin/env bash
# Collect static files
python manage.py collectstatic
# Initialize database
python manage.py makemigrations
python manage.py migrate
# Initialize admin users
python manage.py initadmin
# Run server
exec
gunicorn oser_backend.wsgi:application
\
--bind
0.0.0.0:8000
\
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment