From 8f87f5a556a13c9dd972f5527659114257b01692 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 9 Jan 2024 14:33:12 -0500 Subject: [PATCH 01/33] [OS] ARM64 Docker Builder Push --- .github/workflows/docker-image.yml | 57 +++++++++++++++++++----------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d116444..d1ebdf7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -13,32 +13,47 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout backend code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Build and push the Docker image for backend - run: | - if [ ${{ github.event_name }} == 'pull_request' ]; then - DOCKER_IMAGE_TAG=development - else - DOCKER_IMAGE_TAG=production - fi - docker build ./backend -t themanwholikestocode/archive-me-prod:backend-$DOCKER_IMAGE_TAG - echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - docker push themanwholikestocode/archive-me-prod:backend-$DOCKER_IMAGE_TAG + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to DockerHub + run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + + - name: Build and push the Docker image for backend + uses: docker/build-push-action@v5 + with: + context: ./backend + file: ./backend/Dockerfile + platforms: linux/arm64 + push: true + tags: | + themanwholikestocode/archive-me-prod:backend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} frontend-build: runs-on: ubuntu-latest steps: - name: Checkout frontend code uses: actions/checkout@v3 - + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + - name: Build and push the Docker image for frontend - run: | - if [ ${{ github.event_name }} == 'pull_request' ]; then - DOCKER_IMAGE_TAG=development - else - DOCKER_IMAGE_TAG=production - fi - docker build ./frontend -t themanwholikestocode/archive-me-prod:frontend-$DOCKER_IMAGE_TAG - echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - docker push themanwholikestocode/archive-me-prod:frontend-$DOCKER_IMAGE_TAG + uses: docker/build-push-action@v5 + with: + context: ./frontend + file: ./frontend/Dockerfile + platforms: linux/arm64 + push: true + tags: | + themanwholikestocode/archive-me-prod:frontend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} From f384671cb6bdacc9d66a8023123f1b055ac2a094 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Tue, 9 Jan 2024 18:38:40 -0500 Subject: [PATCH 02/33] Added ENV Variable --- .gitignore | 1 + backend/app.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index eaf1d5d..9d62838 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ client_secrets.json *.pyc mycreds.txt backend/settings.yaml +backend/.env \ No newline at end of file diff --git a/backend/app.py b/backend/app.py index a464246..f9b7e6f 100644 --- a/backend/app.py +++ b/backend/app.py @@ -52,6 +52,8 @@ def clean_up_and_upload_files_to_google_drive(file_path=None): def authorize_drive(): gauth = GoogleAuth(settings_file='settings.yaml') gauth.LocalWebserverAuth() + creds = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") + gauth.credentials = creds drive = GoogleDrive(gauth) return drive From 2a4af15ee9b13e84cc07dca5ff4b0014ac3ce895 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Tue, 9 Jan 2024 19:41:01 -0500 Subject: [PATCH 03/33] Add Error Catching to Google Drive Authentication --- backend/app.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/app.py b/backend/app.py index f9b7e6f..dd99b96 100644 --- a/backend/app.py +++ b/backend/app.py @@ -51,9 +51,12 @@ def clean_up_and_upload_files_to_google_drive(file_path=None): def authorize_drive(): gauth = GoogleAuth(settings_file='settings.yaml') - gauth.LocalWebserverAuth() - creds = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") - gauth.credentials = creds + creds = os.environ["GOOGLE_APPLICATION_CREDENTIALS"] + if creds: + gauth.LoadCredentialsFile(creds) + else: + app.logger.error("Error loading Google Drive credentials") + return None drive = GoogleDrive(gauth) return drive @@ -263,6 +266,10 @@ def list_root_directory(): drive = authorize_drive() + if not drive: + app.logger.error("Error authorizing Google Drive") + exit(1) + team_drive_id = '0AFReXfsUal4rUk9PVA' scheduler.init_app(app) From 69b660f616d709180e2a7964f3520483959038ec Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Tue, 9 Jan 2024 20:03:20 -0500 Subject: [PATCH 04/33] Additional Attempt to get Creds --- backend/app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/app.py b/backend/app.py index dd99b96..82f2577 100644 --- a/backend/app.py +++ b/backend/app.py @@ -52,6 +52,10 @@ def clean_up_and_upload_files_to_google_drive(file_path=None): def authorize_drive(): gauth = GoogleAuth(settings_file='settings.yaml') creds = os.environ["GOOGLE_APPLICATION_CREDENTIALS"] + + if not creds: + creds = os.environ.get("GOOGLE_DRIVE_CREDENTIALS") + if creds: gauth.LoadCredentialsFile(creds) else: From 3eae669452f3010abd09b477eef50615ca8b009a Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Tue, 9 Jan 2024 21:44:19 -0500 Subject: [PATCH 05/33] OS Client ID and Secret --- .gitignore | 4 ---- backend/__pycache__/app.cpython-311.pyc | Bin 7361 -> 0 bytes .../blackboard_scraper.cpython-311.pyc | Bin 21991 -> 0 bytes backend/__pycache__/config.cpython-311.pyc | Bin 1192 -> 0 bytes .../__pycache__/file_management.cpython-311.pyc | Bin 11272 -> 0 bytes .../__pycache__/pdf_compressor.cpython-311.pyc | Bin 5685 -> 0 bytes backend/app.py | 16 +++++++--------- backend/settings.yaml | 16 ++++++++++++++++ 8 files changed, 23 insertions(+), 13 deletions(-) delete mode 100644 backend/__pycache__/app.cpython-311.pyc delete mode 100644 backend/__pycache__/blackboard_scraper.cpython-311.pyc delete mode 100644 backend/__pycache__/config.cpython-311.pyc delete mode 100644 backend/__pycache__/file_management.cpython-311.pyc delete mode 100644 backend/__pycache__/pdf_compressor.cpython-311.pyc create mode 100644 backend/settings.yaml diff --git a/.gitignore b/.gitignore index 9d62838..6da986f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,4 @@ - backend/client_secrets.json client_secrets.json -*.pyc -*.pyc mycreds.txt -backend/settings.yaml backend/.env \ No newline at end of file diff --git a/backend/__pycache__/app.cpython-311.pyc b/backend/__pycache__/app.cpython-311.pyc deleted file mode 100644 index 19efd5bfeab03b05318800213f36b3693b4d1332..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7361 zcmb_gU2GdilJ4Qmki#EoEK$*)Es2sG+q4rgi0rlF*tv})TaGO|dn;{rmoEgx8A+7+ zqx1|TnEaPs3m_j^Mde%JRk~D zxE#rINiOe8`tp2|&kIQ*FDAvjKk4VN-j@sHrKH62d@h&|B}4geGR(e(TqNI?Y-4#b z*PfS?GRymO?a6j%>(3oX9$@c|WQUKaoZ9&XN61(3cTzH{Mwi=bUz=UET;p49Uw*0f z?QP8wklC@^U8{wBPc6R{Xyu(Iigbr4!7qF;2KYNE*$Yy7zkrXgYDFa3r$#sX-Oq-M z5>mp8+*ZUZLutE1nj{?DS3WEXDQQ4Ls9 z3$&O|DOsv!^dh}!i|P3y)#IEUTvg{4n*Bhfai1N{6&F+4f?iC`=hB($^Tjk(>|Uj~ zTF4dCN-7O<%Gs4vrdZI`0=90?&;*lDh`8_B->p4`fOd)TyURno0}ly!s_) z3!0i+(6CYL$BD!*ph8P9-7KZ`#8fd;%0mM!F`d;fmF5!@uGU_y4l*$hdIbF^(km-t zD>rQ^1^UhEsZ_bgJB_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N?s{Dd~Pfy6=DR$={pgs6~z%Ea+T(@Oq;Wq+(!jFIT@{V}t1#OfTW$j><8qrMOO*3WD#Z2YRyXL3g@?#Qn1 z0C#wo0Qmz?d`I1qBXA;Q+;41@HWusLG6#o6Aa!mmIb7v7!o!a)JUWf+;}$o*>kA`0 z5M)2;mK<`~M@{aq1q1N4bH{fH5M+GWEs51eao*(mEUs_6I)!s4*K2XTyFQK^gzcIe z#Ad+Ii|>A5+!e6KPlU*N`3c`=@O|4t;G^jer|48uv)?XSZ(gfR Vo5H)6@UBsNc6lQ7LmLLj{{bP&5hDNq diff --git a/backend/__pycache__/blackboard_scraper.cpython-311.pyc b/backend/__pycache__/blackboard_scraper.cpython-311.pyc deleted file mode 100644 index 6ea5ea09c0452541a6dff12737192934296758af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21991 zcmd6PYj7J^mR>i|02(g>BtQ~;f#5@=z^C}oi=y5nB}yVCS+YHrWn(}#BtZfJP6IS8 z4&dd^Dp`zIDbtFo#Pxb&WXe0knbE}DsYynu+9W$O9*-xxNxG3vfa)x(Shb~8&Hkdx zGZn{wl5=hYjR#5F%A;zV&C|DU-+S(}&pr1$r}2HO)kMMZ6$h~g-Y4pG;XD}9Y7_nK=Oa@Ahbk}GqKAy?fs9l7eS>EWsg8Rpn)ERA`!A>*9s znu&y&ka^B>%`#`bW+nH!P{o|>nvI0@A^TkAwJH)egdB6uYfhTdPyyz4b-scSuE~cV zv)_YS{s{h+BbT-|e;;s_KEGDS8Shco>Nyk82F?t$F`&KOluyrD?or=^n;+#PsB3P{ z3aOg83ZNd&2DF8<18wChfwpl~K-)P7&^;V|h4MOoi+QKLv}`>U@Gr!IHx@!yA`9~n zVO$K%aD4E!0PoevHPewR3$wSzLxH(KI5z(JY+ybXjD%(T)!0nRrY33EYA9mQf^49tuXt}pt7F^JHG0geGg??06o9Mm|Kf}8CJ zN0)XNO&Kw*+P%d&I8Axln6B_V4nzK!`JM*468@Eg*TktSR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-$8N}EN{m74hOIc2oR@%&XqV0P^c6_;ZhhyN|6v??tl>wFX;fKD30!TwbN@G6g^;G zhitZjgMTu+?#+zdn;E}1GjRtqc2)KDC+bE$3U?44DSWur%k#3YMdq23b=-KLGH?iECM=?Fe$!Hg$|_braj7F3H*FHz2Q@ z=c`yk8YaX`@;p+BRMs%BSg!Z5lj53#4HEc!y*zK2Jdq4kHf!EchlB7YPpUfa5=p^+ zAFj!oi}31}>c~}0yc9N?&YGzxs-bxO9i^%>1@Q#SHY=)zGrD9j0Eq}!Bv*4p*)-Vk zj!3ZMFe%Bj1gF7O`%%lr6|$U8_)iJeu%WtoW(${F9cNnYXUx{+*x{yPAveFi=toux z#WjEM%~G+D&xs4gw;Q>lxH7l4}S! zFT-Dlw^PTE`UN9LFtYc)4(SG@DWp4Cp$?M`n4~b-#^~s?I!rZSio#SI+*_{0L<1%$ zOtdjNI$eis1F{sdO>pc8#_0G9`tlu}VTa`#kf)Hp#?RD2Xn;ULI8My`oTKqsR(DWe Spxod35pDZ1OE&C2*7jd#>?~gZ diff --git a/backend/__pycache__/file_management.cpython-311.pyc b/backend/__pycache__/file_management.cpython-311.pyc deleted file mode 100644 index f22f58025b375e8820fe9342fa7a1990db528302..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11272 zcmeHNe^47&e&3Z=(n>-ggoMBrAY*JSFxZa4!B}8pW8=ht&ow#6G=$39wJlpn!lqW%qM@`o;$c)AFQ zC5odsI!ukLcY2(Lye_Pp(vRzDT&52*Q-*N^Ni$*Nlxf^V(uOcQWga&}+IW{5w{Rw) zR*nT)!I^>DI1A89&I+`Ob8r=R>2W(}gIqON3Dm(=0j=TeK%HDQDWNY?zM9|R?v46r zMIV@+h8r7r-LX4weoQ=^x_S_()7RFcgZNow;)0Bz|%w z8bDmf#UKhy^XR}8D1m++AWcpMB7ti>uF^SuTe0QeI0+vupgMS!87|@PfXq|t4Nc3J zR>uBjVtFD<84Y^~k=XhqljIgpXPos}%3y|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}+YGrK&dS8Zw^A^n0Rb5}(5pY64j516a8O zh1UYzsO!jhcC8#=J^$qdemX{;;#u$ zH>7xR&yhzq$$mz*pAqe6o@F~WNAo*S_zy4{MFuB!x;o1mo!I0AqZ3>#!}oNteC65( z$L)JMRyQV-b@gTa9R%N943A}@f2WfWb5F+kUWjG;fp$+s}U_H7XYVTD5w z$N>omQ-PgC8g$wl0?JsXC7J`k+{VQmJYSzn5g#dbI33IbhM^?;x|;9KM@+ z1C04H@(5u$B7YemJLjkyXYnosi7%5-p{i^)6%e*a3AQ65D0p2EJpfWa73F5ad_P)% zGQ1pwcA(&M({zS1&y!z7M~faMJzru)Lyap%ocDQM* diff --git a/backend/__pycache__/pdf_compressor.cpython-311.pyc b/backend/__pycache__/pdf_compressor.cpython-311.pyc deleted file mode 100644 index 4f616e267a189d937ce4f90f81f8a48d5b1ddbed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5685 zcmbVQUu@gP87C!5q$tXNV#iKmIcC}Byo= zQgO}NfLi1s8w|`S0>s5qz!-uqL;R436$tjyK6V2JkOlz@1Pl}y`j9slSzq$9eRr~G z$w|7dC+c{2-@m*2j^Fnq{~U?%6qIj97v#BmiuxDsRElq-@pKXzcPT`TQiw*rEImq- zyKmG_?#w7d?t#$&xd%ssh(-Qe^eBs%Thu6r0#Ju!9tCd@otogIc+r$A(u83U<689 zoyu#nu8WrkhQx6tE9(iKKfN)Cd9w0NIji^aB9!hv5y|6HA!~?nQOZuKx*;k^&KXKt z%3^IvuprC1F7a5ei1Lc4Oi3A8C$c?#A{Z*$ii;CUW*x>8tOSxQR}fD?!)^8lLp>$ zBYsnnr{iiaJF_WRyB>Z(&dWJiczUK!JOle`ly^44U&@IWrSzqd>!Om=4Jn%yZz>Yr z;%fEK)T|GM zZVE^&Y`vkGpag6Xva%*1kp}xwN|#aw?)>yI)DLdBxy$)T6UVH`86 z!b)xYAVF|kO3Nmf+=#|zC|QZEFt`yX&0vzmK$G2w%CUfkA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Dkn|J z5C_N&$9GZG_P|YRu2dJHp%bum7eP`g5vr%d=5SAomnXbi+_|z;_NmcmDK3-;OxdFYt zj2kdEVu2qlJ@l;o3_piLMim}I{Brm!n8!nJE&U;J3_TgweIEC=XS74J8Ic@ z)73!6+db{jOAu?VJGM}S}qGkHbM0yelQi+~uVFF{C;!8WRAGYG7oH zc9{t|n>T%N)eOYr08Gs8|EZ%4Upy=d!fBI_$19M*Y_A4tN|}0HX|5lT(IPkj>V9GDc>tW|3zO$2+Ak4@WB!p6+ zgGjo5c!6+vq7M)11Zuf{*j=p`Pc~TI6fK530Lbz)1g^61@dlurtij6k8Al$Xff~wU}0$x$ZF6E#~?rg;~s4T^|ry%3)F#ld7g=zizT#A0^cH z9OgZXd9Ru}`6y})yicefI1DKHV3W!{h(0b@Z)FH|!eJ&XW}*~sTn$H8!cjZC+X?S3 z4q!mqFnN-Z-s5Q*!B_#zmBu*2)!n3o4>R;aPRyBW|?2@>|5#VdwlfU6L#m@ zPUqXUaK#a>SOTEYy7~G=<{r1S_x=H!i#uH0;^J!@KOb7yd#BUp+8nOU;@Zk~X4WYt z(2b28Uocm~d#v!DC3OD=+}4B^u=dW<)%&AXwA&VX9HGamTt9fk>sB;j3rR;vT9s=( z1S*MMlG$A@mBKDgrQk?o$H&6j>u}S41C`6FdIARoa(u|yDjyphG|34pqZE8Rup*3M zQmMaCL^DA#&$u_HR8+{yZ)z8S3By7C3#b5w(DZtpKr?`4p^8#;L$MzJN>p8u{7O`$ zNPZ=%(W+b}iZ7DidN4sZty8tt7|qgvTD+>cgNCJg)c{Q~!fkWKzti&XEHPYh;M1X7 QLq+mi_fyO+7$#HyFCscO Date: Tue, 9 Jan 2024 21:51:00 -0500 Subject: [PATCH 06/33] Update requirements.txt --- backend/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/requirements.txt b/backend/requirements.txt index d5177b0..2c00e5b 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -7,3 +7,4 @@ gunicorn flask_cors flask_apscheduler pydrive2 +yaml \ No newline at end of file From 9922cf207a7cb62e45c8a584f66d27a826c278b2 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Tue, 9 Jan 2024 21:52:11 -0500 Subject: [PATCH 07/33] Revert "Update requirements.txt" This reverts commit 2fc1a7a62caf139b23ba399f3efae5f1a53e089e. --- backend/requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index 2c00e5b..d5177b0 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -7,4 +7,3 @@ gunicorn flask_cors flask_apscheduler pydrive2 -yaml \ No newline at end of file From 9742ed87cbc9ab1e0ae0a80495dd0c8b46c4de81 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Tue, 9 Jan 2024 22:17:58 -0500 Subject: [PATCH 08/33] Client Secret Test --- .gitignore | 5 ++++- backend/Dockerfile | 6 ++++-- frontend/__pycache__/app.cpython-311.pyc | Bin 1640 -> 0 bytes frontend/__pycache__/config.cpython-311.pyc | Bin 248 -> 0 bytes frontend/__pycache__/wsgi.cpython-311.pyc | Bin 340 -> 0 bytes 5 files changed, 8 insertions(+), 3 deletions(-) delete mode 100644 frontend/__pycache__/app.cpython-311.pyc delete mode 100644 frontend/__pycache__/config.cpython-311.pyc delete mode 100644 frontend/__pycache__/wsgi.cpython-311.pyc diff --git a/.gitignore b/.gitignore index 6da986f..d0b6aa4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ backend/client_secrets.json client_secrets.json mycreds.txt -backend/.env \ No newline at end of file +backend/.env +*.pyc +*.DS_Store +backend/support/.DS_Store diff --git a/backend/Dockerfile b/backend/Dockerfile index 397a86a..6c797f9 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -4,10 +4,12 @@ WORKDIR /backend ADD . /backend +ARG CLIENT_SECRET_JSON + +RUN echo "$CLIENT_SECRET_JSON" > /backend/client_secret.json + RUN pip install -r requirements.txt EXPOSE 5001 CMD python ./app.py - - diff --git a/frontend/__pycache__/app.cpython-311.pyc b/frontend/__pycache__/app.cpython-311.pyc deleted file mode 100644 index 4db6fb95bbd6eb100e248e922213b7ddc3e73188..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1640 zcmbtSy>Ht_6o1DLkrFK@jU3mq0i#PH3AN1v9XizL&=gU+ID^p+TnI`$*|hng94WW< zQYA1Dqf>?g$56RS~OU84^%J7hdpqulT%dR+Ux{jC}WeG1q2SY8>3i_w(Kac+ASd&D_fM zk8=IBaurLf&u`_{+0|9&k#6Y}UU0yx0%X;$_0_KU>hJh2UF%!E;#+yg_cmQ{jYFOr z0Jg&8EEkk!6nEiubv_c$fxIhbYw=%1wn~|L*LUK>>;|KuOPQU}pzk{g%``?I3}~EW z+CdzJUhg=o#T;VySQOZ<$7nZ+*m0&horonZl9hj?9hZ4WleD0YUl6l9LkO^V zaGrm{#ZyR%bOSG=d8)h6l6Foi9w+tF)_xNBF9}n)*Go9(5-#qT-^Y~2X2*BBhx<-q zej9ZM0S%MbYn>4B;PR z_1X5wXpW6$sx%qa*okVoG>AUzF=Y%P-omOpCc~l@(HY*GDQIRjuHNQzhRatYqcJub zsnWRQQZb9~|1d&}MV#wdl?x0*TB}G6|4V#Ry7t+~*ccldsj?xsWx8z#ju+bYiT3%H z=)4$|{U}aaA7^S0OO0U#h+HxiwGs*qh0aB$$JD2xHwai6w^9^mnjh`$dEs7G>PBJD z+rwKzC!n^S$vl&pA!@RJ-1B^jHe9*Q=s2<0y>scJe7AG=ex|Z$kWi6u@zdf>nal>^ zm26z-+d=hYC1y-Lli>_V-#ZwQxsDQb1;J@OGsvy zFatvsk8^%rNorn+Zb)T8s-GtFEmjv-r%?A>ECK#OA-8y({eyzzJzO1KT!VsFGJFOZ z`O8f|v^ce>SU)KzF*!RUu|(e`Ke;p)XhyNVduEA8X_CGZNG2&iu_#41IJqdXAhk$8 ztq5#Sihgo_URq|lUP0wA4x8Nkl+v73yCM#tu^LOB2c diff --git a/frontend/__pycache__/wsgi.cpython-311.pyc b/frontend/__pycache__/wsgi.cpython-311.pyc deleted file mode 100644 index a8854afaa4ae334587b8a7d8de649abc8a730661..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 340 zcmZ3^%ge<81S4BO~Jt2H^{+=m9f#N7W@}$qUSqH(1zP+}pjIyc>O6d>g><12Y4Q6i}*&184#O DrxQ`W From f02df94c738cef110d22e9b4f09f1c514d464595 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 9 Jan 2024 22:18:12 -0500 Subject: [PATCH 09/33] Update docker-image.yml --- .github/workflows/docker-image.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d1ebdf7..494ea7e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -33,6 +33,9 @@ jobs: push: true tags: | themanwholikestocode/archive-me-prod:backend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} + build-args: | + CLIENT_SECRET_JSON=${{ secrets.CLIENT_SECRET_JSON }} + frontend-build: runs-on: ubuntu-latest steps: From dc5589cc97ea272fd39624c0c1428b7b0a93f823 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Tue, 9 Jan 2024 22:30:24 -0500 Subject: [PATCH 10/33] Added Secrets --- backend/app.py | 3 ++- backend/settings.yaml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/app.py b/backend/app.py index 8235d15..e2d63c2 100644 --- a/backend/app.py +++ b/backend/app.py @@ -58,7 +58,8 @@ def authorize_drive(): settings['client_config']['client_secret'] = os.environ.get('GOOGLE_CLIENT_SECRET') gauth = GoogleAuth(settings=settings) - gauth.LocalWebserverAuth() + gauth.LoadCredentialsFile("credentials.json") + drive = GoogleDrive(gauth) return drive diff --git a/backend/settings.yaml b/backend/settings.yaml index 21a52aa..3e5bca3 100644 --- a/backend/settings.yaml +++ b/backend/settings.yaml @@ -1,4 +1,5 @@ client_config_backend: settings +client_secrets_file: client_secrets.json client_config: client_id: ${GOOGLE_CLIENT_ID} client_secret: ${GOOGLE_CLIENT_SECRET} From c8d9d42f9b05e9a9347965359b8929a4d4f4d1a5 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Wed, 10 Jan 2024 14:24:42 -0500 Subject: [PATCH 11/33] Load environmental variables --- backend/app.py | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/backend/app.py b/backend/app.py index e2d63c2..70f69e1 100644 --- a/backend/app.py +++ b/backend/app.py @@ -3,13 +3,17 @@ import threading import time import uuid + +from dotenv import load_dotenv from flask import Flask, abort, after_this_request, jsonify, request, send_from_directory from flask_cors import CORS, cross_origin from flask_apscheduler import APScheduler import yaml + from blackboard_scraper import BlackboardSession from file_management import clean_up_session_files, delete_session_files, list_files_in_drive_folder, update_drive_directory, clean_up_docs_files import config + from pydrive2.auth import GoogleAuth from pydrive2.drive import GoogleDrive @@ -23,6 +27,9 @@ # Initialize Logging logging.basicConfig(level=logging.INFO) +# Import dot env variables +load_dotenv() + def is_file_valid(file_path): return os.path.isfile(file_path) and not os.path.islink(file_path) @@ -35,9 +42,10 @@ def remove_file_safely(file_path): except OSError as error: app.logger.error(f"Error removing file: {error}") + @scheduler.task('interval', id='clean_up', seconds=600) def clean_up_and_upload_files_to_google_drive(file_path=None): - + if file_path: remove_file_safely(file_path) @@ -55,11 +63,17 @@ def authorize_drive(): settings = yaml.safe_load(file) settings['client_config']['client_id'] = os.environ.get('GOOGLE_CLIENT_ID') - settings['client_config']['client_secret'] = os.environ.get('GOOGLE_CLIENT_SECRET') + settings['client_config']['client_secret'] = os.environ.get( + 'GOOGLE_CLIENT_SECRET') gauth = GoogleAuth(settings=settings) - gauth.LoadCredentialsFile("credentials.json") - + + if os.path.isfile("credentials.json"): + gauth.LoadCredentialsFile("credentials.json") + else: + gauth.LocalWebserverAuth() + gauth.SaveCredentialsFile("credentials.json") + drive = GoogleDrive(gauth) return drive @@ -138,6 +152,7 @@ def delete_inactive_bb_sessions(inactivity_threshold_seconds=180): def index(): return jsonify({'message': "Welcome to the ArchiveMe's Blackboard Scraper API"}) + @app.route('/login', methods=['POST']) @cross_origin() def login(): @@ -228,9 +243,9 @@ def list_directory(path): # Check if there's only one file returned if len(items) == 1 and items[0][3] == 'FILE': # Assuming 'file_id' and 'file_name' are available based on the user selection - file_id = items[0][2] - file_name = items[0][0] - + file_id = items[0][2] + file_name = items[0][0] + # Update the session_files_path based on the current directory and create if it doesn't exist current_dir = os.path.dirname(os.path.abspath(__file__)) if os.path.basename(current_dir) != 'backend': @@ -243,9 +258,9 @@ def list_directory(path): if not os.path.exists(session_files_path): os.makedirs(session_files_path) full_path = os.path.join(session_files_path, file_name) - + file = drive.CreateFile({'id': file_id}) - print('Downloading file %s from Google Drive' % file_name) + print('Downloading file %s from Google Drive' % file_name) file.GetContentFile(full_path) @after_this_request @@ -254,9 +269,9 @@ def trigger_post_download_operations(response): target=clean_up_and_upload_files_to_google_drive, args=(full_path,)) thread.start() return response - + return send_from_directory(session_files_path, file_name, as_attachment=True) - + return jsonify(items) @@ -266,7 +281,7 @@ def list_root_directory(): if __name__ == '__main__': - + drive = authorize_drive() if not drive: @@ -278,4 +293,4 @@ def list_root_directory(): scheduler.init_app(app) scheduler.start() - app.run(host='0.0.0.0', port=app.config['PORT'], debug=app.config['DEBUG']) \ No newline at end of file + app.run(host='0.0.0.0', port=app.config['PORT'], debug=app.config['DEBUG']) From 622fb59dfe24695ecd0d923fe5cf32fe8bb34c46 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Wed, 10 Jan 2024 14:58:20 -0500 Subject: [PATCH 12/33] Removed unused settings --- backend/requirements.txt | 1 + backend/settings.yaml | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index d5177b0..2c16bf2 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -7,3 +7,4 @@ gunicorn flask_cors flask_apscheduler pydrive2 +dotenv \ No newline at end of file diff --git a/backend/settings.yaml b/backend/settings.yaml index 3e5bca3..ee9a4fb 100644 --- a/backend/settings.yaml +++ b/backend/settings.yaml @@ -3,9 +3,6 @@ client_secrets_file: client_secrets.json client_config: client_id: ${GOOGLE_CLIENT_ID} client_secret: ${GOOGLE_CLIENT_SECRET} - auth_uri: https://accounts.google.com/o/oauth2/auth - token_uri: https://oauth2.googleapis.com/token - redirect_uri: http://localhost:8080 save_credentials: True save_credentials_backend: file From dce0983b02d2a84cb93c930f5c28442e3c3db254 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Wed, 10 Jan 2024 15:00:43 -0500 Subject: [PATCH 13/33] Update requirements.txt --- backend/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index 2c16bf2..3605f18 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -7,4 +7,4 @@ gunicorn flask_cors flask_apscheduler pydrive2 -dotenv \ No newline at end of file +python-dotenv \ No newline at end of file From 3faeef039674d9a3aefeef4934a1d5348627ff48 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Wed, 10 Jan 2024 15:31:31 -0500 Subject: [PATCH 14/33] Refresh Auth Token --- backend/app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/app.py b/backend/app.py index 70f69e1..d5a65b8 100644 --- a/backend/app.py +++ b/backend/app.py @@ -74,6 +74,10 @@ def authorize_drive(): gauth.LocalWebserverAuth() gauth.SaveCredentialsFile("credentials.json") + if gauth.access_token_expired: + gauth.Refresh() + gauth.SaveCredentialsFile("credentials.json") + drive = GoogleDrive(gauth) return drive From da86ec1983c0f99773b2833479f84b0150b459d6 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Wed, 10 Jan 2024 16:01:51 -0500 Subject: [PATCH 15/33] Credentials in GH Secrets --- .github/workflows/docker-image.yml | 2 ++ backend/Dockerfile | 10 +++++++++- backend/settings.yaml | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 494ea7e..cbdd11b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -35,6 +35,8 @@ jobs: themanwholikestocode/archive-me-prod:backend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} build-args: | CLIENT_SECRET_JSON=${{ secrets.CLIENT_SECRET_JSON }} + GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} + GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} frontend-build: runs-on: ubuntu-latest diff --git a/backend/Dockerfile b/backend/Dockerfile index 6c797f9..136aa80 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -4,9 +4,17 @@ WORKDIR /backend ADD . /backend +ARG GOOGLE_CLIENT_SECRET + +ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET + +ARG GOOGLE_CLIENT_ID + +ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID + ARG CLIENT_SECRET_JSON -RUN echo "$CLIENT_SECRET_JSON" > /backend/client_secret.json +RUN echo "$CLIENT_CREDENTIALS_JSON" > /backend/credentials.json RUN pip install -r requirements.txt diff --git a/backend/settings.yaml b/backend/settings.yaml index ee9a4fb..df67398 100644 --- a/backend/settings.yaml +++ b/backend/settings.yaml @@ -1,5 +1,4 @@ client_config_backend: settings -client_secrets_file: client_secrets.json client_config: client_id: ${GOOGLE_CLIENT_ID} client_secret: ${GOOGLE_CLIENT_SECRET} From 1312a675c57556cfbefe65b6462884ce5b0e7c2f Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Wed, 10 Jan 2024 16:14:58 -0500 Subject: [PATCH 16/33] CLIENT_CREDENTIALS_JSON --- backend/Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 136aa80..3540bf1 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -5,15 +5,12 @@ WORKDIR /backend ADD . /backend ARG GOOGLE_CLIENT_SECRET - ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET ARG GOOGLE_CLIENT_ID - ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID -ARG CLIENT_SECRET_JSON - +ARG CLIENT_CREDENTIALS_JSON RUN echo "$CLIENT_CREDENTIALS_JSON" > /backend/credentials.json RUN pip install -r requirements.txt From 590224e8f6c1adc8276dc283e36428060ec99ee9 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Wed, 10 Jan 2024 17:13:08 -0500 Subject: [PATCH 17/33] Update Dockerfile --- backend/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/Dockerfile b/backend/Dockerfile index 3540bf1..2d95574 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -11,6 +11,7 @@ ARG GOOGLE_CLIENT_ID ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID ARG CLIENT_CREDENTIALS_JSON +ENV CLIENT_CREDENTIALS_JSON=$CLIENT_CREDENTIALS_JSON RUN echo "$CLIENT_CREDENTIALS_JSON" > /backend/credentials.json RUN pip install -r requirements.txt From b186ce0c2ab2231f17c14a689c83ecec529aba16 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 10 Jan 2024 19:15:45 -0500 Subject: [PATCH 18/33] Update docker-image.yml --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index cbdd11b..bfc3256 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -34,7 +34,7 @@ jobs: tags: | themanwholikestocode/archive-me-prod:backend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} build-args: | - CLIENT_SECRET_JSON=${{ secrets.CLIENT_SECRET_JSON }} + CLIENT_CREDENTIALS_JSON=${{ secrets.CLIENT_CREDENTIALS_JSON }} GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} From b3315325a0a5f84c75f8b0c8bb4f019f39600fd3 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Wed, 10 Jan 2024 20:27:04 -0500 Subject: [PATCH 19/33] ports --- .github/workflows/docker-image.yml | 13 +++++++++++-- backend/Dockerfile | 8 +++++--- frontend/Dockerfile | 2 -- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index bfc3256..132df11 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -8,6 +8,12 @@ on: release: types: [published] +env: + PROD_BACKEND_PORT: 5001 + DEV_BACKEND_PORT: 5003 + PROD_FRONTEND_PORT: 5002 + DEV_FRONTEND_PORT: 5004 + jobs: backend-build: runs-on: ubuntu-latest @@ -32,11 +38,12 @@ jobs: platforms: linux/arm64 push: true tags: | - themanwholikestocode/archive-me-prod:backend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} + themanwholikestocode/archive-me-prod:backend-${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && 'development' || 'production' }} build-args: | CLIENT_CREDENTIALS_JSON=${{ secrets.CLIENT_CREDENTIALS_JSON }} GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} + PORT=${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && env.DEV_BACKEND_PORT || env.PROD_BACKEND_PORT }} frontend-build: runs-on: ubuntu-latest @@ -61,4 +68,6 @@ jobs: platforms: linux/arm64 push: true tags: | - themanwholikestocode/archive-me-prod:frontend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} + themanwholikestocode/archive-me-prod:frontend-${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && 'development' || 'production' }} + build-args: | + PORT=${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && env.DEV_FRONTEND_PORT || env.PROD_FRONTEND_PORT }} \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile index 2d95574..612530a 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -14,8 +14,10 @@ ARG CLIENT_CREDENTIALS_JSON ENV CLIENT_CREDENTIALS_JSON=$CLIENT_CREDENTIALS_JSON RUN echo "$CLIENT_CREDENTIALS_JSON" > /backend/credentials.json -RUN pip install -r requirements.txt +ARG PORT +ENV PORT=$PORT +EXPOSE $PORT -EXPOSE 5001 +RUN pip install -r requirements.txt -CMD python ./app.py +CMD python ./app.py \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 05a97d9..2cd33c3 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -6,6 +6,4 @@ ADD . /frontend RUN pip install -r requirements.txt -EXPOSE 5002 - CMD python ./app.py \ No newline at end of file From 2c8eab5f239e09638d995ac88ae28960caac09db Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 10 Jan 2024 20:45:33 -0500 Subject: [PATCH 20/33] Update docker-image.yml --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 132df11..10addfb 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -43,7 +43,7 @@ jobs: CLIENT_CREDENTIALS_JSON=${{ secrets.CLIENT_CREDENTIALS_JSON }} GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} - PORT=${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && env.DEV_BACKEND_PORT || env.PROD_BACKEND_PORT }} + PORT=${{ (github.event_name == 'pull_request' || github.ref == 'refs/heads/main') && env.DEV_BACKEND_PORT || env.PROD_BACKEND_PORT }} frontend-build: runs-on: ubuntu-latest @@ -70,4 +70,4 @@ jobs: tags: | themanwholikestocode/archive-me-prod:frontend-${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && 'development' || 'production' }} build-args: | - PORT=${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && env.DEV_FRONTEND_PORT || env.PROD_FRONTEND_PORT }} \ No newline at end of file + PORT=${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && env.DEV_FRONTEND_PORT || env.PROD_FRONTEND_PORT }} From c73c7e93b8af640e851e4826053b1c7326dc34c7 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 10 Jan 2024 20:51:25 -0500 Subject: [PATCH 21/33] Update docker-image.yml --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 10addfb..b2e6d45 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -43,7 +43,7 @@ jobs: CLIENT_CREDENTIALS_JSON=${{ secrets.CLIENT_CREDENTIALS_JSON }} GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} - PORT=${{ (github.event_name == 'pull_request' || github.ref == 'refs/heads/main') && env.DEV_BACKEND_PORT || env.PROD_BACKEND_PORT }} + PORT=${{ github.event_name != 'pull_request' && env.PROD_BACKEND_PORT || env.DEV_BACKEND_PORT }} frontend-build: runs-on: ubuntu-latest @@ -70,4 +70,4 @@ jobs: tags: | themanwholikestocode/archive-me-prod:frontend-${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && 'development' || 'production' }} build-args: | - PORT=${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && env.DEV_FRONTEND_PORT || env.PROD_FRONTEND_PORT }} + PORT=${{ github.event_name != 'pull_request' && env.PROD_FRONTEND_PORT || env.DEV_FRONTEND_PORT }} From 8505392d86c1e7b2dce3b90d7bd9135a73d18ff3 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Wed, 10 Jan 2024 20:56:50 -0500 Subject: [PATCH 22/33] removed port from config --- backend/app.py | 2 +- backend/config.py | 3 +-- frontend/app.py | 2 +- frontend/config.py | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/app.py b/backend/app.py index d5a65b8..6505001 100644 --- a/backend/app.py +++ b/backend/app.py @@ -297,4 +297,4 @@ def list_root_directory(): scheduler.init_app(app) scheduler.start() - app.run(host='0.0.0.0', port=app.config['PORT'], debug=app.config['DEBUG']) + app.run(host='0.0.0.0', debug=app.config['DEBUG']) diff --git a/backend/config.py b/backend/config.py index 802de4d..263290b 100644 --- a/backend/config.py +++ b/backend/config.py @@ -2,5 +2,4 @@ from selenium.webdriver.chrome.options import Options # Flask configuration -DEBUG = True # Set to False in production -PORT = 5001 # Port number for the Flask server \ No newline at end of file +DEBUG = True # Set to False in production \ No newline at end of file diff --git a/frontend/app.py b/frontend/app.py index 9317831..d737119 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -35,4 +35,4 @@ def login(): return jsonify(success=True) if __name__ == '__main__': - app.run(host='0.0.0.0', port=app.config['PORT'], debug=app.config['DEBUG']) + app.run(host='0.0.0.0', debug=app.config['DEBUG']) diff --git a/frontend/config.py b/frontend/config.py index 26fd0a1..4003ce1 100644 --- a/frontend/config.py +++ b/frontend/config.py @@ -2,7 +2,6 @@ # Flask configuration DEBUG = True # Set to False in production -PORT = 5002 # Port number for the Flask server # CORS Configurations CORS_HEADERS = 'Content-Type' From aa23a7d7c2ae8c9cf0cde320459eaa1258eddd29 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 18:18:13 -0500 Subject: [PATCH 23/33] fixed name tags --- .github/workflows/docker-image.yml | 4 ++-- .gitignore | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b2e6d45..0cf3368 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -38,7 +38,7 @@ jobs: platforms: linux/arm64 push: true tags: | - themanwholikestocode/archive-me-prod:backend-${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && 'development' || 'production' }} + themanwholikestocode/archive-me-prod:backend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} build-args: | CLIENT_CREDENTIALS_JSON=${{ secrets.CLIENT_CREDENTIALS_JSON }} GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} @@ -68,6 +68,6 @@ jobs: platforms: linux/arm64 push: true tags: | - themanwholikestocode/archive-me-prod:frontend-${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' && 'development' || 'production' }} + themanwholikestocode/archive-me-prod:frontend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} build-args: | PORT=${{ github.event_name != 'pull_request' && env.PROD_FRONTEND_PORT || env.DEV_FRONTEND_PORT }} diff --git a/.gitignore b/.gitignore index d0b6aa4..78a3d75 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ backend/client_secrets.json client_secrets.json mycreds.txt backend/.env +frontend/.env *.pyc *.DS_Store backend/support/.DS_Store From 0080ebb597f0999c25e67be59c2d63f881b59a9b Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 18:48:44 -0500 Subject: [PATCH 24/33] Updated Flask Ports --- backend/app.py | 4 ++-- backend/config.py | 19 ++++++++++++++++--- frontend/app.py | 2 +- frontend/config.py | 21 ++++++++++++++++----- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/backend/app.py b/backend/app.py index 6505001..3babe44 100644 --- a/backend/app.py +++ b/backend/app.py @@ -77,7 +77,7 @@ def authorize_drive(): if gauth.access_token_expired: gauth.Refresh() gauth.SaveCredentialsFile("credentials.json") - + drive = GoogleDrive(gauth) return drive @@ -297,4 +297,4 @@ def list_root_directory(): scheduler.init_app(app) scheduler.start() - app.run(host='0.0.0.0', debug=app.config['DEBUG']) + app.run(host='0.0.0.0', port=app.config['PORT'], debug=app.config['DEBUG']) diff --git a/backend/config.py b/backend/config.py index 263290b..c1dde59 100644 --- a/backend/config.py +++ b/backend/config.py @@ -1,5 +1,18 @@ # config.py -from selenium.webdriver.chrome.options import Options - +import os +from dotenv import load_dotenv +import sys # Flask configuration -DEBUG = True # Set to False in production \ No newline at end of file +load_dotenv() + +env = os.environ.get('ENVIRONMENT') + +if env == 'dev': + PORT = 5003 + DEBUG = True +elif env == 'prod': + PORT = 5001 + DEBUG = False +else: + print("Environment not specified. Please provide a valid environment.") + sys.exit(1) diff --git a/frontend/app.py b/frontend/app.py index d737119..9317831 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -35,4 +35,4 @@ def login(): return jsonify(success=True) if __name__ == '__main__': - app.run(host='0.0.0.0', debug=app.config['DEBUG']) + app.run(host='0.0.0.0', port=app.config['PORT'], debug=app.config['DEBUG']) diff --git a/frontend/config.py b/frontend/config.py index 4003ce1..de0cb9f 100644 --- a/frontend/config.py +++ b/frontend/config.py @@ -1,11 +1,22 @@ # config.py +import os +from dotenv import load_dotenv +import sys # Flask configuration -DEBUG = True # Set to False in production +load_dotenv() + +env = os.environ.get('ENVIRONMENT') + +if env == 'dev': + PORT = 5004 + DEBUG = True +elif env == 'prod': + PORT = 5002 + DEBUG = False +else: + print("Environment not specified. Please provide a valid environment.") + sys.exit(1) # CORS Configurations CORS_HEADERS = 'Content-Type' - -# Security configurations -# It's advisable to use environment variables for sensitive data -# Example: SECRET_KEY = os.environ.get('SECRET_KEY') or 'a-default-secret' From ed5924777de715278dd8f591fed5e10bf4be8208 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 19:05:20 -0500 Subject: [PATCH 25/33] Updating Pathing and Ports --- backend/app.py | 11 ++++++++++- frontend/app.py | 7 +------ frontend/config.json | 6 ++++++ frontend/static/helpers.js | 14 ++++++++++++++ frontend/static/scripts.js | 5 ++++- 5 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 frontend/config.json create mode 100644 frontend/static/helpers.js diff --git a/backend/app.py b/backend/app.py index 3babe44..9a352b4 100644 --- a/backend/app.py +++ b/backend/app.py @@ -59,7 +59,16 @@ def clean_up_and_upload_files_to_google_drive(file_path=None): def authorize_drive(): - with open('settings.yaml', 'r') as file: + current_directory = os.getcwd() + + if 'backend' in current_directory: + settings_path = 'settings.yaml' + elif 'Archive-Me' in current_directory: + settings_path = 'backend/settings.yaml' + else: + raise Exception("Unable to locate settings file.") + + with open(settings_path, 'r') as file: settings = yaml.safe_load(file) settings['client_config']['client_id'] = os.environ.get('GOOGLE_CLIENT_ID') diff --git a/frontend/app.py b/frontend/app.py index 9317831..cfbfe95 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -1,4 +1,4 @@ -from flask import Flask, render_template, request, jsonify, send_from_directory, abort +from flask import Flask, render_template from flask_cors import CORS, cross_origin import os import logging @@ -28,11 +28,6 @@ def demo(): def directory(): return render_template('directory.html') -# Add a login route for demonstration -@app.route('/login', methods=['POST']) -def login(): - # Your login logic here - return jsonify(success=True) if __name__ == '__main__': app.run(host='0.0.0.0', port=app.config['PORT'], debug=app.config['DEBUG']) diff --git a/frontend/config.json b/frontend/config.json new file mode 100644 index 0000000..0e03787 --- /dev/null +++ b/frontend/config.json @@ -0,0 +1,6 @@ +{ + "apiUrl":{ + "dev":"http://localhost:5003", + "prod":"https://api.archive-me.net" + } +} \ No newline at end of file diff --git a/frontend/static/helpers.js b/frontend/static/helpers.js new file mode 100644 index 0000000..e115664 --- /dev/null +++ b/frontend/static/helpers.js @@ -0,0 +1,14 @@ +import config from 'frontend/config.json' + +function getEnv() { + if (!process.env) { + throw new Error('Process environment not found.'); + } + return process.env.ENVIRONMENT +} + +function getApiUrl() { + return config.apiUrl[getEnv()] +} + +export { getEnv, getApiUrl } \ No newline at end of file diff --git a/frontend/static/scripts.js b/frontend/static/scripts.js index a619196..cd776a7 100755 --- a/frontend/static/scripts.js +++ b/frontend/static/scripts.js @@ -1,3 +1,5 @@ +import { getApiUrl } from "./helpers"; + $(function () { // init feather icons feather.replace(); @@ -83,7 +85,8 @@ $(function () { const app = (() => { let fileKeyGlobal = null; let currentPath = ''; - const apiUrl = 'https://api.archive-me.net'; + + const apiUrl = getApiUrl(); const showLoadingScreen = () => { const loadingScreen = document.getElementById("loading-screen"); From 27372a4ee1dc265dfe9f82a50ad0ae2471999245 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 19:10:42 -0500 Subject: [PATCH 26/33] Switched port to env --- backend/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 612530a..0065d09 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -14,9 +14,8 @@ ARG CLIENT_CREDENTIALS_JSON ENV CLIENT_CREDENTIALS_JSON=$CLIENT_CREDENTIALS_JSON RUN echo "$CLIENT_CREDENTIALS_JSON" > /backend/credentials.json -ARG PORT -ENV PORT=$PORT -EXPOSE $PORT +ARG ENVIRONMENT +ENV ENVIRONMENT=$ENVIRONMENT RUN pip install -r requirements.txt From 7acda80ded912377e326c65eb168fd5aad6b71de Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 19:16:53 -0500 Subject: [PATCH 27/33] Test ENV pass --- .github/workflows/docker-image.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0cf3368..4005c5e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -43,6 +43,7 @@ jobs: CLIENT_CREDENTIALS_JSON=${{ secrets.CLIENT_CREDENTIALS_JSON }} GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} + ENVIRONTMENT=${{ github.event_name == 'pull_request' && 'development' || 'production' }} PORT=${{ github.event_name != 'pull_request' && env.PROD_BACKEND_PORT || env.DEV_BACKEND_PORT }} frontend-build: @@ -70,4 +71,5 @@ jobs: tags: | themanwholikestocode/archive-me-prod:frontend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} build-args: | + ENVIRONTMENT=${{ github.event_name == 'pull_request' && 'development' || 'production' }} PORT=${{ github.event_name != 'pull_request' && env.PROD_FRONTEND_PORT || env.DEV_FRONTEND_PORT }} From daa2fa4dff7e1de511a3c539b705d034438c0f6d Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 19:21:36 -0500 Subject: [PATCH 28/33] spelling PAIN --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4005c5e..11dd3d0 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -43,7 +43,7 @@ jobs: CLIENT_CREDENTIALS_JSON=${{ secrets.CLIENT_CREDENTIALS_JSON }} GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} - ENVIRONTMENT=${{ github.event_name == 'pull_request' && 'development' || 'production' }} + ENVIRONMENT=${{ github.event_name == 'pull_request' && 'dev' || 'prod' }} PORT=${{ github.event_name != 'pull_request' && env.PROD_BACKEND_PORT || env.DEV_BACKEND_PORT }} frontend-build: @@ -71,5 +71,5 @@ jobs: tags: | themanwholikestocode/archive-me-prod:frontend-${{ github.event_name == 'pull_request' && 'development' || 'production' }} build-args: | - ENVIRONTMENT=${{ github.event_name == 'pull_request' && 'development' || 'production' }} + ENVIRONMENT=${{ github.event_name == 'pull_request' && 'dev' || 'prod' }} PORT=${{ github.event_name != 'pull_request' && env.PROD_FRONTEND_PORT || env.DEV_FRONTEND_PORT }} From 3b9e227f6bc3a3ff2481f9ab71f52a58c73cc8f1 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 19:29:52 -0500 Subject: [PATCH 29/33] Expose ports --- backend/Dockerfile | 5 +++++ frontend/Dockerfile | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/backend/Dockerfile b/backend/Dockerfile index 0065d09..052669d 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -17,6 +17,11 @@ RUN echo "$CLIENT_CREDENTIALS_JSON" > /backend/credentials.json ARG ENVIRONMENT ENV ENVIRONMENT=$ENVIRONMENT +ARG PORT +ENV PORT=$PORT + +EXPOSE $PORT + RUN pip install -r requirements.txt CMD python ./app.py \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 2cd33c3..2aa350a 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -6,4 +6,9 @@ ADD . /frontend RUN pip install -r requirements.txt +ARG PORT +ENV PORT=$PORT + +EXPOSE $PORT + CMD python ./app.py \ No newline at end of file From 00442818e131257839ee47d9580d8a11955cdbaa Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 19:56:20 -0500 Subject: [PATCH 30/33] Update requirements.txt --- frontend/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/requirements.txt b/frontend/requirements.txt index 5c38da7..cd26aff 100644 --- a/frontend/requirements.txt +++ b/frontend/requirements.txt @@ -5,4 +5,5 @@ ray argparse bs4 gunicorn -flask_cors \ No newline at end of file +flask_cors +python-dotenv \ No newline at end of file From 87b2187ec53023bdcdebddf86bdcf88057ed17ae Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 20:08:17 -0500 Subject: [PATCH 31/33] Update Dockerfile --- frontend/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 2aa350a..8900a26 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -6,6 +6,9 @@ ADD . /frontend RUN pip install -r requirements.txt +ARG ENVIRONMENT +ENV ENVIRONMENT=$ENVIRONMENT + ARG PORT ENV PORT=$PORT From 11d8421e7f81df39b07d970dce8b8475db5e4a2f Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 20:18:34 -0500 Subject: [PATCH 32/33] House Keeping --- frontend/static/helpers.js | 5 +++++ frontend/static/scripts.js | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/static/helpers.js b/frontend/static/helpers.js index e115664..1018839 100644 --- a/frontend/static/helpers.js +++ b/frontend/static/helpers.js @@ -8,6 +8,11 @@ function getEnv() { } function getApiUrl() { + + if (!config.apiUrl[getEnv()]) { + throw new Error('Api url not found.'); + } + return config.apiUrl[getEnv()] } diff --git a/frontend/static/scripts.js b/frontend/static/scripts.js index cd776a7..96bcccf 100755 --- a/frontend/static/scripts.js +++ b/frontend/static/scripts.js @@ -1,5 +1,3 @@ -import { getApiUrl } from "./helpers"; - $(function () { // init feather icons feather.replace(); From 2d22fb86794964aa40fd25d2c9df13df65981ce1 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Thu, 11 Jan 2024 20:50:48 -0500 Subject: [PATCH 33/33] Update Urls Based on Host --- frontend/static/helpers.js | 26 +++++++++++++++++--------- frontend/static/scripts.js | 2 ++ frontend/templates/demo.html | 2 +- frontend/templates/directory.html | 2 +- frontend/templates/index.html | 2 +- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/frontend/static/helpers.js b/frontend/static/helpers.js index 1018839..1e31f32 100644 --- a/frontend/static/helpers.js +++ b/frontend/static/helpers.js @@ -1,19 +1,27 @@ -import config from 'frontend/config.json' +function getConfig() { + const config = { + apiUrl: { + dev: "http://localhost:5003", + prod: "https://api.archive-me.net" + } + }; + return config; +} function getEnv() { - if (!process.env) { - throw new Error('Process environment not found.'); - } - return process.env.ENVIRONMENT + const hostname = window.location.hostname; + return hostname.includes('localhost') ? 'dev' : 'prod'; } function getApiUrl() { - - if (!config.apiUrl[getEnv()]) { + const config = getConfig(); + const env = getEnv(); + + if (!config.apiUrl[env]) { throw new Error('Api url not found.'); } - return config.apiUrl[getEnv()] + return config.apiUrl[env]; } -export { getEnv, getApiUrl } \ No newline at end of file +export { getEnv, getApiUrl }; diff --git a/frontend/static/scripts.js b/frontend/static/scripts.js index 96bcccf..b0bc296 100755 --- a/frontend/static/scripts.js +++ b/frontend/static/scripts.js @@ -1,3 +1,5 @@ +import { getApiUrl } from './helpers.js'; + $(function () { // init feather icons feather.replace(); diff --git a/frontend/templates/demo.html b/frontend/templates/demo.html index 75cb4d6..ed4bdfc 100644 --- a/frontend/templates/demo.html +++ b/frontend/templates/demo.html @@ -108,7 +108,7 @@
About Archive Me
- + \ No newline at end of file diff --git a/frontend/templates/directory.html b/frontend/templates/directory.html index 1b561e5..c4d737a 100644 --- a/frontend/templates/directory.html +++ b/frontend/templates/directory.html @@ -61,7 +61,7 @@

Directory Listing for /path/to/directory

- + \ No newline at end of file diff --git a/frontend/templates/index.html b/frontend/templates/index.html index f2590ca..0a6e65a 100755 --- a/frontend/templates/index.html +++ b/frontend/templates/index.html @@ -351,7 +351,7 @@
Help
- + \ No newline at end of file