-
Notifications
You must be signed in to change notification settings - Fork 3
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
Part 1: infra changes #70
Open
AlexandreOndet
wants to merge
4
commits into
backend+accounts+rankings
Choose a base branch
from
1_infra
base: backend+accounts+rankings
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.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eec30ad
infra changes
AlexandreOndet 0435478
Merge pull request #65 from AlexandreOndet/1_infra
AlexandreOndet 656a230
fixes after Jon's comment + bonus env fix
AlexandreOndet 27bad49
removes backend service from docker-compose (until we make it work wi…
AlexandreOndet 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 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,6 @@ | ||
app/node_modules | ||
app/npm-debug.log | ||
app/build | ||
node_modules | ||
npm-debug.log | ||
back/venv |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
NODE_LOCAL_PORT=2003 | ||
NODE_DOCKER_PORT=2003 | ||
|
||
FLASK_LOCAL_PORT=8083 | ||
FLASK_DOCKER_PORT=8083 | ||
FRONT_ADDRESS=http://localhost | ||
|
||
REACT_APP_API_BASE_URL=http://localhost:8003 | ||
|
||
NODE_ENV=DEV | ||
ENV=DEV | ||
|
||
WCA_CLIENT_ID=example-id | ||
WCA_CLIENT_SECRET=example-secret | ||
WCA_HOST=https://staging.worldcubeassociation.org | ||
SESSION_SECRET_KEY=12340987 | ||
DATASTORE_EMULATOR_HOST=localhost:8081 | ||
GOOGLE_CLOUD_PROJECT=scc-staging-391105 | ||
|
||
ADMIN_WCA_ID=2017ONDE01 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file specifies files that are *not* uploaded to Google Cloud | ||
# using gcloud. It follows the same syntax as .gitignore, with the addition of | ||
# "#!include" directives (which insert the entries of the given .gitignore-style | ||
# file at that point). | ||
|
||
^(.*/)?#.*#$ | ||
^(.*/)?.*~$ | ||
^(.*/)?.*\.py[co]$ | ||
^(.*/)?\..*$ | ||
external/bootstrap | ||
__pycache__/ | ||
/src/ | ||
/lib/ | ||
.git/ | ||
.gitignore | ||
env/ | ||
back/venv/ | ||
app/node_modules/ | ||
|
||
# Ignore other unnecessary files | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
*.pyc | ||
*.egg-info/ | ||
*.egg | ||
*.bak | ||
*.swp | ||
*.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM node:16-alpine AS development | ||
ENV NODE_ENV development | ||
|
||
WORKDIR / | ||
COPY app/package.json ./ | ||
COPY package-lock.json ./ | ||
RUN npm install | ||
|
||
COPY . . | ||
WORKDIR /app | ||
|
||
CMD ["npm", "start"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file specifies files that are *not* uploaded to Google Cloud | ||
# using gcloud. It follows the same syntax as .gitignore, with the addition of | ||
# "#!include" directives (which insert the entries of the given .gitignore-style | ||
# file at that point). | ||
|
||
^(.*/)?#.*#$ | ||
^(.*/)?.*~$ | ||
^(.*/)?.*\.py[co]$ | ||
^(.*/)?\..*$ | ||
external/bootstrap | ||
__pycache__/ | ||
/src/ | ||
/lib/ | ||
.git/ | ||
.gitignore | ||
env/ | ||
venv/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
runtime: nodejs16 | ||
AlexandreOndet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
handlers: | ||
# Serve all static files with url ending with a file extension | ||
- url: /(.*\..+)$ | ||
static_files: build/\1 | ||
upload: build/(.*\..+)$ | ||
|
||
# Catch all handler to index.html | ||
- url: /.* | ||
static_files: build/index.html | ||
upload: build/index.html |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file specifies files that are *not* uploaded to Google Cloud | ||
# using gcloud. It follows the same syntax as .gitignore, with the addition of | ||
# "#!include" directives (which insert the entries of the given .gitignore-style | ||
# file at that point). | ||
|
||
^(.*/)?#.*#$ | ||
^(.*/)?.*~$ | ||
^(.*/)?.*\.py[co]$ | ||
^(.*/)?\..*$ | ||
external/bootstrap | ||
__pycache__/ | ||
/src/ | ||
/lib/ | ||
.git/ | ||
.gitignore | ||
env/ | ||
venv/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
service: api | ||
runtime: python311 | ||
entrypoint: gunicorn -b :$PORT backend:app | ||
|
||
env_variables: | ||
ENV: "PROD" | ||
WCA_HOST: "https://staging.worldcubeassociation.org" | ||
|
||
handlers: | ||
- url: /.* | ||
script: auto | ||
secure: always |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
indexes: | ||
- kind: User | ||
properties: | ||
- name: wca_person | ||
- name: name_lower | ||
- name: name | ||
|
||
- kind: User | ||
properties: | ||
- name: name_lower | ||
- name: name | ||
|
||
# AUTOGENERATED | ||
|
||
# This index.yaml is automatically updated whenever the dev_appserver | ||
# detects that a new type of query is run. If you want to manage the | ||
# index.yaml file manually, remove the above marker line (the line | ||
# saying "# AUTOGENERATED"). If you want to manage some indexes | ||
# manually, move them above the marker line. The index.yaml file is | ||
# automatically uploaded to the admin console when you next deploy | ||
# your application using appcfg.py. | ||
|
||
- kind: Champion | ||
properties: | ||
- name: event | ||
- name: year | ||
- name: region | ||
|
||
- kind: Championship | ||
properties: | ||
- name: national_championship | ||
- name: region | ||
- name: year | ||
direction: desc | ||
|
||
- kind: Championship | ||
properties: | ||
- name: national_championship | ||
- name: province | ||
- name: year | ||
direction: desc | ||
|
||
- kind: Championship | ||
properties: | ||
- name: national_championship | ||
- name: year | ||
direction: desc | ||
|
||
- kind: Championship | ||
properties: | ||
- name: region | ||
- name: year | ||
direction: desc | ||
|
||
- kind: Championship | ||
properties: | ||
- name: province | ||
- name: year | ||
direction: desc | ||
|
||
- kind: Championship | ||
properties: | ||
- name: year | ||
- name: region | ||
|
||
- kind: Competition | ||
properties: | ||
- name: country | ||
- name: name | ||
|
||
- kind: Competition | ||
properties: | ||
- name: year | ||
- name: end_date | ||
|
||
- kind: Competition | ||
properties: | ||
- name: year | ||
- name: end_date | ||
direction: desc | ||
|
||
- kind: RankAverage | ||
properties: | ||
- name: event | ||
- name: province | ||
- name: best | ||
|
||
- kind: RankSingle | ||
properties: | ||
- name: event | ||
- name: province | ||
- name: best | ||
|
||
- kind: Result | ||
properties: | ||
- name: competition | ||
- name: event | ||
- name: round_type | ||
- name: pos | ||
direction: desc | ||
|
||
- kind: Result | ||
properties: | ||
- name: competition | ||
- name: pos | ||
|
||
- kind: Result | ||
properties: | ||
- name: competition | ||
- name: pos | ||
direction: desc | ||
|
||
- kind: UserLocationUpdate | ||
properties: | ||
- name: user | ||
- name: update_time | ||
|
||
- kind: UserLocationUpdate | ||
properties: | ||
- name: user | ||
- name: update_time | ||
direction: desc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#!/usr/bin/env bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a particular reason why this is a bash script? I feel that a Python script would be more readable for most people. I would expect that the environment that this script will be run on (either CI or a developer's machine) would have Python install. |
||
|
||
# Arguments: | ||
# -p: deploy to prod | ||
# -s: deploy to staging | ||
# -f: frontend only | ||
# -b: backend only | ||
# -v <app version>: On staging, the name of the app version to upload. | ||
|
||
set -e | ||
|
||
PROJECT="" | ||
IS_PROD=0 | ||
VERSION="" | ||
FRONTEND_ONLY=0 | ||
BACKEND_ONLY=0 | ||
|
||
while getopts "psfbv:" opt; do | ||
case $opt in | ||
p) | ||
PROJECT="scc-production-398617" | ||
IS_PROD=1 | ||
;; | ||
s) | ||
PROJECT="scc-staging-391105" | ||
IS_PROD=0 | ||
;; | ||
f) | ||
FRONTEND_ONLY=1 | ||
;; | ||
b) | ||
BACKEND_ONLY=1 | ||
;; | ||
v) | ||
VERSION="$OPTARG" | ||
if [ "$VERSION" == "admin" ] | ||
then | ||
echo "You can't use -v admin. Please select another version name." | ||
exit 1 | ||
fi | ||
;; | ||
\?) | ||
echo "Invalid option: -$OPTARG" >&2 | ||
exit 1 | ||
;; | ||
:) | ||
echo "Option -$OPTARG requires an argument." >&2 | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
|
||
if [ -z "$PROJECT" ] | ||
then | ||
echo "Either -p (prod) or -s (staging) must be set." >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ $FRONTEND_ONLY -eq 1 ] && [ $BACKEND_ONLY -eq 1 ] | ||
then | ||
echo "Cannot set both -f (frontend only) and -b (backend only)." >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ "$IS_PROD" == "1" -a ! -z "$VERSION" ] | ||
then | ||
echo "You can't specify a version for the prod app." >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ "$IS_PROD" == "0" -a -z "$VERSION" ] | ||
then | ||
echo "You must specify a version with -v for the staging app." >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ $BACKEND_ONLY -eq 1 ] | ||
then | ||
echo "Deploying backend only." | ||
CMD="gcloud app deploy back/api.yaml --project $PROJECT" | ||
if [ ! -z "$VERSION" ] | ||
then | ||
CMD="$CMD --version $VERSION" | ||
fi | ||
echo "$CMD" | ||
$CMD | ||
exit 0 | ||
fi | ||
|
||
echo "Recompiling react." | ||
rm -rf app/build | ||
cd app | ||
if [ "$IS_PROD" == "0" ] | ||
then | ||
echo "Setting REACT_APP_API_BASE_URL to staging." | ||
export REACT_APP_API_BASE_URL="https://api.staging.speedcubingcanada.org" | ||
else | ||
echo "Setting REACT_APP_API_BASE_URL to prod." | ||
export REACT_APP_API_BASE_URL="https://api.speedcubingcanada.org" | ||
fi | ||
npm run build | ||
cd .. | ||
|
||
if [ $FRONTEND_ONLY -eq 1 ] | ||
then | ||
echo "Deploying frontend only." | ||
CMD="gcloud app deploy app/app.yaml --project $PROJECT" | ||
else | ||
echo "Deploying to App Engine." | ||
CMD="gcloud app deploy app/app.yaml dispatch.yaml back/api.yaml --project $PROJECT" | ||
fi | ||
|
||
if [ ! -z "$VERSION" ] | ||
then | ||
CMD="$CMD --version $VERSION" | ||
fi | ||
|
||
echo "$CMD" | ||
$CMD | ||
|
||
if [ ! -z "$VERSION" ] | ||
then | ||
URI="https://${VERSION}-dot-$PROJECT.appspot.com" | ||
else | ||
URI="https://$PROJECT.appspot.com" | ||
fi | ||
echo "Successfully uploaded to $URI." | ||
|
||
if [ ! -z "$VERSION" ] | ||
then | ||
echo "Once you're done testing, please clean up by running:" | ||
echo "gcloud app versions delete $VERSION --project $PROJECT" | ||
fi |
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.
Again, Node v20 would be preferred.
Additionally, is there a reason why you're using an Alpine image? Alpine can be the cause of many issues.