-
Notifications
You must be signed in to change notification settings - Fork 337
✨(buildpack) add PaaS deployment support, tested with Scalingo #1020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sylvinus
wants to merge
1
commit into
main
Choose a base branch
from
buildpack
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+170
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
web: bin/buildpack_start.sh | ||
postdeploy: python manage.py migrate |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit # always exit on error | ||
set -o pipefail # don't ignore exit codes when piping output | ||
|
||
echo "-----> Running post-compile script" | ||
|
||
rm -rf docker docs env.d gitlint src/frontend/apps/e2e | ||
rm -rf src/frontend/apps | ||
rm -rf src/frontend/packages | ||
|
||
# Remove some of the larger packages required by the frontend only | ||
rm -rf src/frontend/node_modules/@next src/frontend/node_modules/next src/frontend/node_modules/react-icons src/frontend/node_modules/@gouvfr-lasuite | ||
|
||
# du -ch | sort -rh | head -n 100 |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit # always exit on error | ||
set -o pipefail # don't ignore exit codes when piping output | ||
|
||
echo "-----> Running post-frontend script" | ||
|
||
# Move the frontend build to the nginx root and clean up | ||
mkdir -p build/ | ||
mv src/frontend/apps/impress/out build/frontend-out | ||
|
||
mv src/backend/* ./ | ||
mv src/nginx/* ./ | ||
|
||
echo "3.13" > .python-version |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# Start the Django backend server | ||
gunicorn -b :8000 impress.wsgi:application --log-file - & | ||
|
||
# Start the Y provider service | ||
cd src/frontend/servers/y-provider && PORT=4444 ../../.scalingo/node/bin/node dist/start-server.js & | ||
|
||
# Start the Nginx server | ||
bin/run & | ||
|
||
# if the current shell is killed, also terminate all its children | ||
trap "pkill SIGTERM -P $$" SIGTERM | ||
|
||
# wait for a single child to finish, | ||
wait -n | ||
# then kill all the other tasks | ||
pkill -P $$ |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# ERB templated nginx configuration | ||
# see https://doc.scalingo.com/platform/deployment/buildpacks/nginx | ||
|
||
upstream backend_server { | ||
server localhost:8000 fail_timeout=0; | ||
} | ||
|
||
upstream collaboration_server { | ||
server localhost:4444 fail_timeout=0; | ||
} | ||
|
||
server { | ||
|
||
listen <%= ENV["PORT"] %>; | ||
server_name _; | ||
|
||
root /app/build/frontend-out; | ||
|
||
error_page 404 /404.html; | ||
|
||
location /collaboration/api/ { | ||
proxy_set_header X-Forwarded-Proto https; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
||
proxy_redirect off; | ||
proxy_pass http://collaboration_server; | ||
} | ||
|
||
location /collaboration/ws/ { | ||
|
||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
|
||
# Set appropriate timeout for WebSocketAdd commentMore actions | ||
proxy_read_timeout 86400; | ||
proxy_send_timeout 86400; | ||
|
||
proxy_set_header X-Forwarded-Proto https; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
||
proxy_redirect off; | ||
proxy_pass http://collaboration_server; | ||
} | ||
|
||
# Django rest framework | ||
location ^~ /api/ { | ||
proxy_set_header X-Forwarded-Proto https; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
||
proxy_redirect off; | ||
proxy_pass http://backend_server; | ||
} | ||
|
||
# Django admin | ||
location ^~ /admin/ { | ||
proxy_set_header X-Forwarded-Proto https; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
||
proxy_redirect off; | ||
proxy_pass http://backend_server; | ||
} | ||
|
||
# Proxy auth for media | ||
location /media/ { | ||
# Auth request configuration | ||
auth_request /media-auth; | ||
auth_request_set $authHeader $upstream_http_authorization; | ||
auth_request_set $authDate $upstream_http_x_amz_date; | ||
auth_request_set $authContentSha256 $upstream_http_x_amz_content_sha256; | ||
|
||
# Pass specific headers from the auth response | ||
proxy_set_header Authorization $authHeader; | ||
proxy_set_header X-Amz-Date $authDate; | ||
proxy_set_header X-Amz-Content-SHA256 $authContentSha256; | ||
|
||
# Get resource from Object Storage | ||
proxy_pass <%= ENV["AWS_S3_ENDPOINT_URL"] %>/<%= ENV["AWS_STORAGE_BUCKET_NAME"] %>/; | ||
proxy_set_header Host <%= ENV["AWS_S3_ENDPOINT_URL"].split("://")[1] %>; | ||
|
||
add_header Content-Security-Policy "default-src 'none'" always; | ||
} | ||
|
||
location /media-auth { | ||
proxy_pass http://backend_server/api/v1.0/documents/media-auth/; | ||
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-Original-URL $request_uri; | ||
|
||
# Prevent the body from being passed | ||
proxy_pass_request_body off; | ||
proxy_set_header Content-Length ""; | ||
proxy_set_header X-Original-Method $request_method; | ||
} | ||
|
||
|
||
location / { | ||
try_files $uri index.html $uri/ =404; | ||
} | ||
|
||
location ~ "^/docs/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/?$" { | ||
try_files $uri /docs/[id]/index.html; | ||
} | ||
|
||
location = /404.html { | ||
internal; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: we should not hardcode the node binary path here.