Skip to content

Commit

Permalink
Merge pull request #13 from pmhalvor/cline/home-refactor
Browse files Browse the repository at this point in the history
Refactor: Notion integration running on Flask

Nginx has been updated to point to the docker container running the gunicorn server serving the flask app that is my site
  • Loading branch information
pmhalvor authored Mar 6, 2025
2 parents c54976b + 34e719d commit 59d51a9
Show file tree
Hide file tree
Showing 60 changed files with 1,191 additions and 246 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/docker-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}

# # Build the image using docker-compose (with platform option, if set in your compose file)
# - name: Build image via docker-compose
# run: docker compose build
# Make empty .env file to avoid error in GHA
- name: Create empty .env file
run: |
echo "" >> .env
# # Push the image(s) defined in docker-compose.yml to the registry
# - name: Push image via docker-compose
# run: docker compose push
# Build the image using docker-compose (with platform option, if set in your compose file)
- name: Build image via docker-compose
run: docker compose build

# Push the image(s) defined in docker-compose.yml to the registry
- name: Push image via docker-compose
run: docker compose push
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/siteenv

*/.data
sitedb
.cache
duck*
old_*

config.json

Expand All @@ -10,11 +14,12 @@ _environ.json

*.pyc

Dockerfile*
entry*
.travis.yml
.env*

*.code*
*/.vscode
*/worker/store/duration_df.pkl

notion_cache/
18 changes: 18 additions & 0 deletions Dockerfile.home
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.11-slim

WORKDIR /new_home

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY new_home/*.py ./
COPY new_home/templates ./templates
COPY new_home/static ./static

ENV FLASK_ENV=production
ARG PORT=5001
ENV PORT=${PORT}

EXPOSE ${PORT}

CMD ["sh", "-c", "gunicorn -b 0.0.0.0:${PORT} app:app"]
16 changes: 16 additions & 0 deletions Dockerfile.radio
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.11-slim

WORKDIR /new_radio

# COPY requirements.txt ./
# RUN pip install --no-cache-dir -r requirements.txt

# COPY new_radio/*.py ./

# ENV FLASK_ENV=production
# ARG PORT=5001
# ENV PORT=${PORT}

# EXPOSE ${PORT}

# CMD ["sh", "-c", "gunicorn -b 0.0.0.0:${PORT} app:app"]
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# build/push/pull the docker images
build:
docker compose build

push:
docker compose push

pull:
git pull
docker compose pull

build-push: build push

pull-up: pull up

# run the server
up:
docker compose up -d

down:
docker compose down

run: up down

restart: down up
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# perhalvorsen.com (master)

Hello and welcome to my site!
# perhalvorsen.com
Repository for my personal website, [perhalvorsen.com](https://perhalvorsen.com).

This master branch represents the latest, stable version of the site.
Checkout the development branch to see what I currently am working on.
Otherwise, take a peek at the previous releases of the site, to see what
changes have been implemented.


Changelog:

I use this site as a portfolio, shining light on some of the web-development
projects I've taken part in.
If there are any malfunctions on your end,
send me an email or pull request, and I'll work on
fixing it.

## Changelog:
- 2.1.0: Updated server to Ubuntu 4.23 and ensure environment vars present
- 2.0.0: Migrated off of Azure. Everything is now soley hosted on Digial Ocean server
- 1.1.4: current, recents, and plots loaded seperately from `/radio`, allowing for smoother user experience
Expand All @@ -22,14 +28,14 @@ Changelog:
- 1.0.1: Static site from previous deploy hosted from server.


I use this site as a portfolio, shining light on some of the web-development
projects I've taken part in.
If there are any malfunctions on your end,
send me an email or pull request, and I'll work on
fixing it.
# Useful commands when developing

## Run site container
Uses `docker compose` to build, run, then tear down the site container.
```sh
make run
```

# Useful commands when developing

## Restart server

Expand Down
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
new_home:
build:
context: .
dockerfile: Dockerfile.home
container_name: new_home
image: ghcr.io/pmhalvor/website:latest
restart: always
ports:
- "5001:5001"
env_file:
- .env
environment:
DEBUG: "false"
platform: linux/amd64

# new_radio:
# build:
# context: .
# dockerfile: Dockerfile.radio
# container_name: new_radio
# restart: always
# ports:
# - "5002:5002"
# env_file:
# - .env
# environment:
# DEBUG: "false"
# platform: linux/amd64
4 changes: 2 additions & 2 deletions home/migrations/0005_auto_20201220_0005.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import datetime
from django.db import migrations, models
from django.utils.timezone import utc
from django.utils import timezone


class Migration(migrations.Migration):
Expand All @@ -25,7 +25,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='update',
name='pub_date',
field=models.DateTimeField(default=datetime.datetime(2020, 12, 20, 0, 5, 38, 84608, tzinfo=utc), verbose_name='pub_date'),
field=models.DateTimeField(default=datetime.datetime(2020, 12, 20, 0, 5, 38, 84608, tzinfo=timezone.get_current_timezone()), verbose_name='pub_date'),
preserve_default=False,
),
]
50 changes: 50 additions & 0 deletions home/prompts_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
prompts_list = [
{
"img_url": "/static/img/chatgpt_logo.png",
"title": "Anomaly detection",
"descr": "Some deep learning approaches to anomaly detection on an image dataset.",
"file_url": "https://chatgpt.com/share/e/9808d736-fc0d-4e97-ad1c-cba4a79b8070",
},
{
"img_url": "/static/img/chatgpt_logo.png",
"title": "Facts about lobsters",
"descr": "Why would lobsters need 12 color receptors?",
"file_url": "https://chat.openai.com/share/40498b9c-4f3f-4221-a2a5-9140ed9905e0",
},
{
"img_url": "/static/img/chatgpt_logo.png",
"title": "Building regex strings",
"descr": "Extracting an S3 bucket name from a full resource path.",
"file_url": "https://chat.openai.com/share/dd5826fe-622c-4208-8d73-b820c628b668",
},
{
"img_url": "/static/img/chatgpt_logo.png",
"title": "Dealing with unbalanced data",
"descr": "Some techniques for dealing with skewed data in ML projects.",
"file_url": "https://chat.openai.com/share/eefbbd37-38eb-42f3-bf4f-948647c706e7",
},
{
"img_url": "/static/img/chatgpt_logo.png",
"title": "Naming Music Workout DJ",
"descr": "Brainstorming potential names for my Endurabeats app.",
"file_url": "https://chat.openai.com/share/0d5764e2-1be3-41af-a1a3-3d3e6ea92b12",
},
{
"img_url": "/static/img/chatgpt_logo.png",
"title": "Activation Functions",
"descr": "A refresher on activation functions and weight decay with an example.",
"file_url": "https://chat.openai.com/share/7dccc3ca-575f-4a00-890e-97ce67424cce",
},
{
"img_url": "/static/img/chatgpt_logo.png",
"title": "Rom-com Movie suggestions",
"descr": "Brainstorming what to watch with a robot assistant.",
"file_url": "https://chat.openai.com/share/b3d02f46-ded9-4ad5-bf6d-7eff8f3f018e",
},
{
"img_url": "/static/img/chatgpt_logo.png",
"title": "Python reduce function",
"descr": "Two breif examples of how 'functools.reduce' works.",
"file_url": "https://chat.openai.com/share/2de6f54c-84d3-40f2-b6bc-76a54b8f2f27",
},
]
15 changes: 5 additions & 10 deletions home/templates/home/code.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title>code</title>
{% load static %}
{% load home_tags %}
<title>code</title>
<link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/code.css' %}">
<link rel="shortcut icon" type="image/png" href="{% static 'favicon.ico' %}"/>
</head>

<body>
{% include "includes/navbar.html" %}
{% include "includes/navbar2.html" %}

<div class="container">
{% for item in code_list %}
<div class="card">
<a href= "{{ item.file_loc.url }}" class="card">
<img src="{{ item.img_loc.url }}" class="card">
<h3>{{ item.title }}</h3>
<p>{{ item.descr }}</p>
</a>
</div>
{% card img_url=item.img_loc.url title=item.title descr=item.descr file_url=item.file_loc.url %}
{% endfor %}
</div>


{% include "includes/footer.html" %}
</body>

</html>
</html>
9 changes: 2 additions & 7 deletions home/templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
{% load static %}
{% load home_tags %}
<title>home</title>
<link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/home.css' %}">
Expand Down Expand Up @@ -42,12 +43,7 @@ <h1> A nerdy, data-oriented, house-enthusiast</h1>
<h2><em>Recent updates:</em></h2>
<div class="row">
{% for item in update_list %}
<div class="card">
<a href="{{ item.file_loc }}" class="card">
<img src="{{ item.img_loc.url }}" class="card">
<h3><em>{{ item.title }}</em></h3>
</a>
</div>
{% card img_url=item.img_loc.url title=item.title descr="" file_url=item.file_loc %}
{% endfor %}
</div>
</div>
Expand All @@ -59,4 +55,3 @@ <h3><em>{{ item.title }}</em></h3>
</body>

</html>

9 changes: 2 additions & 7 deletions home/templates/home/notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<title>notes</title>
{% load static %}
{% load home_tags %}
<link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/notes.css' %}">
<link rel="shortcut icon" type="image/png" href="{% static 'favicon.ico' %}"/>
Expand All @@ -22,13 +23,7 @@

<div class="container">
{% for item in notes_list %}
<div class="card">
<a href="{{ item.file_loc.url }}">
<img src="{{ item.img_loc.url }}" class="card">
<h3>{{ item.title }}</h3>
<p> {{ item.descr }} </p>
</a>
</div>
{% card img_url=item.img_loc.url title=item.title descr=item.descr file_url=item.file_loc.url %}
{% endfor %}

</div>
Expand Down
Loading

0 comments on commit 59d51a9

Please sign in to comment.