Skip to content

Commit 238da66

Browse files
committed
Merge branch 'master' into k8s-helm
2 parents 73e3ce3 + facef08 commit 238da66

File tree

15 files changed

+160
-27
lines changed

15 files changed

+160
-27
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release Containers
2+
3+
on:
4+
push:
5+
tags: [ 'v*' ]
6+
7+
8+
jobs:
9+
release-containers:
10+
name: Build and Push
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- uses: actions/checkout@v2
15+
16+
- name: Login to ghcr.io Docker registry
17+
uses: docker/login-action@v1
18+
with:
19+
registry: ghcr.io
20+
username: ${{ github.repository_owner }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Compute Docker container image addresses
24+
run: |
25+
DOCKER_REPOSITORY="ghcr.io/${GITHUB_REPOSITORY,,}"
26+
DOCKER_TAG="${GITHUB_REF:11}"
27+
echo "DOCKER_REPOSITORY=${DOCKER_REPOSITORY}" >> $GITHUB_ENV
28+
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
29+
echo "Using: ${DOCKER_REPOSITORY}/*:${DOCKER_TAG}"
30+
31+
- name: 'Pull latest existing Docker container image: server'
32+
run: docker pull "${DOCKER_REPOSITORY}/server:latest" || true
33+
34+
- name: 'Pull latest existing Docker container image: client'
35+
run: docker pull "${DOCKER_REPOSITORY}/client:latest" || true
36+
37+
- name: 'Build Docker container image: server'
38+
run: |
39+
docker build \
40+
--cache-from "${DOCKER_REPOSITORY}/server:latest" \
41+
--tag "${DOCKER_REPOSITORY}/server:latest" \
42+
--tag "${DOCKER_REPOSITORY}/server:${DOCKER_TAG}" \
43+
./src/server
44+
45+
- name: Push Docker container image server:latest"
46+
run: docker push "${DOCKER_REPOSITORY}/server:latest"
47+
48+
- name: Push Docker container image server:v*"
49+
run: docker push "${DOCKER_REPOSITORY}/server:${DOCKER_TAG}"
50+
51+
- name: 'Build Docker container image: client'
52+
run: |
53+
docker build \
54+
--cache-from "${DOCKER_REPOSITORY}/client:latest" \
55+
--tag "${DOCKER_REPOSITORY}/client:latest" \
56+
--tag "${DOCKER_REPOSITORY}/client:${DOCKER_TAG}" \
57+
./src/client
58+
59+
- name: Push Docker container image client:latest"
60+
run: docker push "${DOCKER_REPOSITORY}/client:latest"
61+
62+
- name: Push Docker container image client:v*"
63+
run: docker push "${DOCKER_REPOSITORY}/client:${DOCKER_TAG}"

src/client/src/components/Login/Login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function checkLoginResponse(response) {
1212

1313

1414
async function loginUser(credentials) {
15-
return fetch('http://localhost:5000/api/user/login', {
15+
return fetch('/api/user/login', {
1616
method: 'POST',
1717
headers: {
1818
'Content-Type': 'application/json'

src/client/src/components/Refresh.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default async function Refresh(old_token) {
22

33
// Use exisiting token to get a new fresh token
44

5-
const new_at = await fetch('http://localhost:5000/api/user/refresh',
5+
const new_at = await fetch('/api/user/refresh',
66
{
77
method: 'GET',
88
headers: {

src/client/src/pages/Admin.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Admin extends Component {
5555
await this.handleGetFileList();
5656
await this.handleGetStatistics();
5757

58-
this.setState({isLoading: false})
58+
await this.setState({isLoading: false})
5959
}
6060

6161
componentDidMount() {
@@ -78,14 +78,13 @@ class Admin extends Component {
7878
formData.append('file', element, element.name)
7979
})
8080

81-
await fetch("/api/file", {method: 'POST', body: formData,
81+
await fetch("/api/file", {
82+
method: 'POST',
83+
body: formData,
8284
headers: {
83-
'Content-Type': 'application/json',
8485
'Authorization': 'Bearer ' + this.props.access_token
8586
}})
8687

87-
88-
8988
await this.handleGetFileList();
9089

9190
await this.setState({
@@ -105,7 +104,6 @@ class Admin extends Component {
105104
{
106105
method: 'GET',
107106
headers: {
108-
'Content-Type': 'application/json',
109107
'Authorization': 'Bearer ' + this.props.access_token
110108
}
111109
});
@@ -118,7 +116,6 @@ class Admin extends Component {
118116
{
119117
method: 'GET',
120118
headers: {
121-
'Content-Type': 'application/json',
122119
'Authorization': 'Bearer ' + this.props.access_token
123120
}
124121
});
@@ -139,7 +136,6 @@ class Admin extends Component {
139136
{
140137
method: 'GET',
141138
headers: {
142-
'Content-Type': 'application/json',
143139
'Authorization': 'Bearer ' + this.props.access_token
144140
}
145141
});

src/client/src/pages/Check/Check.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function Check({access_token}) {
3535

3636
function authCheck() {
3737
// console.log('authCheck startfetch @ ' + DateTime.local().toFormat('HH:mm:ss.SSS'))
38-
fetch('http://localhost:5000/api/user/test_auth',
38+
fetch('/api/user/test_auth',
3939
{
4040
method: 'GET',
4141
headers: {

src/server/alembic.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ script_location = alembic
3636
# output_encoding = utf-8
3737

3838
# Container
39-
sqlalchemy.url = postgresql://postgres:thispasswordisverysecure@paws-compose-db/paws
39+
sqlalchemy.url = postgresql://postgres:PASSWORD@paws-compose-db/paws
4040

4141
# Local
4242
# sqlalchemy.url = postgresql://postgres:thispasswordisverysecure@localhost/paws

src/server/alembic/env.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from sqlalchemy import engine_from_config
44
from sqlalchemy import pool
55

6+
from os import environ
7+
68
from alembic import context
79

810
# this is the Alembic Config object, which provides
@@ -25,6 +27,13 @@
2527
# ... etc.
2628

2729

30+
PG_URL1 = 'postgresql://postgres:'
31+
PG_URL2 = environ['POSTGRES_PASSWORD']
32+
PG_URL3 = '@paws-compose-db/paws'
33+
34+
PG_URL = PG_URL1 + PG_URL2 + PG_URL3
35+
36+
2837
def run_migrations_offline():
2938
"""Run migrations in 'offline' mode.
3039
@@ -37,7 +46,8 @@ def run_migrations_offline():
3746
script output.
3847
3948
"""
40-
url = config.get_main_option("sqlalchemy.url")
49+
# url = config.get_main_option("sqlalchemy.url")
50+
url = PG_URL
4151
context.configure(
4252
url=url,
4353
target_metadata=target_metadata,
@@ -60,6 +70,7 @@ def run_migrations_online():
6070
config.get_section(config.config_ini_section),
6171
prefix="sqlalchemy.",
6272
poolclass=pool.NullPool,
73+
url=PG_URL,
6374
)
6475

6576
with connectable.connect() as connection:

src/server/api/admin_api.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from api.api import admin_api
2-
import shutil
32
import os
43
from datetime import datetime
54
import json
@@ -16,23 +15,19 @@
1615
from config import (
1716
RAW_DATA_PATH,
1817
CURRENT_SOURCE_FILES_PATH,
19-
LOGS_PATH,
2018
)
2119

2220
ALLOWED_EXTENSIONS = {"csv", "xlsx"}
2321

22+
2423
def __allowed_file(filename):
2524
return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
2625

2726

28-
2927
# file upload tutorial
3028
@admin_api.route("/api/file", methods=["POST"])
3129
@jwt_ops.admin_required
32-
def uploadCSV():
33-
if "file" not in request.files:
34-
return redirect(request.url)
35-
30+
def upload_csv():
3631
for file in request.files.getlist("file"):
3732
if __allowed_file(file.filename):
3833
try:

src/server/api/common_api.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,23 @@
77
import time
88
from datetime import datetime
99
import dateutil.parser
10-
from secrets import SHELTERLUV_SECRET_TOKEN
10+
11+
12+
try:
13+
from secrets import SHELTERLUV_SECRET_TOKEN
14+
except ImportError:
15+
# Not running locally
16+
print("Couldn't get SL_TOKEN from file, trying environment **********")
17+
from os import environ
18+
19+
try:
20+
SHELTERLUV_SECRET_TOKEN = environ['SHELTERLUV_SECRET_TOKEN']
21+
except KeyError:
22+
# Nor in environment
23+
# You're SOL for now
24+
print("Couldn't get secrets from file or environment")
25+
26+
1127

1228
from api import jwt_ops
1329

src/server/app.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@
44

55
from flask_jwt_extended import JWTManager
66

7-
from secrets import JWT_SECRET, APP_SECRET_KEY
7+
try:
8+
from secrets import JWT_SECRET, APP_SECRET_KEY
9+
except ImportError:
10+
# Not running locally
11+
print("Could not get secrets from file, trying environment **********")
12+
from os import environ
13+
14+
try:
15+
JWT_SECRET = environ['JWT_SECRET']
16+
APP_SECRET_KEY = environ['APP_SECRET_KEY']
17+
except KeyError:
18+
# Nor in environment
19+
# You're SOL for now
20+
print("Couldn't get secrets from file or environment")
21+
822

923
app = Flask(__name__)
1024

0 commit comments

Comments
 (0)