An open API service indexing awesome lists of open source software.

https://github.com/ndjenkins85/personalsite

Codebase and assets used to create and manage my personal website
https://github.com/ndjenkins85/personalsite

flask personal-website python-package

Last synced: about 1 month ago
JSON representation

Codebase and assets used to create and manage my personal website

Awesome Lists containing this project

README

          

# Personal site

This repo generates my personal website and resume.
It uses docker for hosting on Heroku.
The site is open to public, and intended for colleagues, friends, family and recruiters.

The site uses flask framework to serve markdown blog posts according to my custom scripts.

* [Installation](#installation)
* [Dependency and virtual environment management, library development and build with poetry](#dependency-and-virtual-environment-management-library-development-and-build-with-poetry)
* [Code quality, testing, and generating documentation with Nox](#code-quality-testing-and-generating-documentation-with-nox)
* [Code formatting with Pre-commit](#code-formatting-with-pre-commit)
* [Running the webserver](#running-the-webserver)
* [Contributors](#contributors)

## Installation

The following are the setup instructions for installing the codebase locally to continue development.
Follow each step here and ensure tests are working.

### Python

This project uses Python 3.12

### Dependency and virtual environment management, library development and build with poetry

Ensure you have and installation of Poetry `2.1.1` or above, along with poetry-version-plugin.

Also add the following extras:

```bash
poetry self add poetry-plugin-shell
poetry self add poetry-plugin-export
```

Set preference for in-project virtual environment
```bash
poetry config virtualenvs.in-project true
```

Make sure you deactivate any existing virtual environments (i.e. conda).

```bash
poetry install
```

You may need to point poetry to the correct python interpreter using the following command.
In another terminal and in conda, run `which python`.
```bash
poetry env use /path/to/python3
```

Library can be built using

```bash
poetry build
```

### Code quality, testing, and generating documentation with Nox

Nox is a python task automation tool similar to Tox, Makefiles or scripts.

The following command can be used to run mypy, lint, and tests.
It is recommended to run these before pushing code, as this is run with Github Actions.
Some checks such as black are run more frequently with [pre-commit](#installing-pre-commit).

```bash
poetry run nox
```

Local Sphinx documentation can be generated with the following command.
Documentation publishing using Github Actions to Github pages is enabled by default.

```bash
poetry run nox -s docs
```

All other task automations commands can be optionally run locally with below command.

```bash
poetry run nox -s black safety pytype typeguard coverage xdoctest autoflake
```

### Code formatting with Pre-commit

On first time use of the repository, pre-commit will need to be installed locally.
You can use the following command to install and run pre-commit over all files.
See .pre-commit-config.yaml for checks in use.
Intention is to have lightweight checks that automatically make code changes.

``` bash
pre-commit run --all-files
```

## Running the webserver

### Local webserver

After following above instructions to use poetry environment, view website locally with following command:

``` bash
python run.py
...
* Serving Flask app 'personalsite' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
```

Visit [localhost](http://127.0.0.1:5000) on browser.

### Containerized webserver

Webserver can be started using docker-compose or Dockerfile. The Heroku publishing via github actions uses Dockerfile.

``` bash
docker-compose build
docker-compose up
docker-compose down
```

Alternatively run from Dockerfile:

``` bash
docker build -t bluemania/personalsite .
docker run -p 5000:5000 -e PORT=5000 --rm bluemania/personalsite
docker stop $(docker ps -a -q)
```

Visit [localhost](http://0.0.0.0:5000) on browser.

### Publish to Heroku

The following commands are used to push the containerized webserver to Heroku.
These steps currently need to be performed in local development environment.

``` bash
heroku login
docker build -t bluemania/personalsite .
heroku container:login
docker tag bluemania/personalsite registry.heroku.com/nickjenkins/web
docker push registry.heroku.com/nickjenkins/web
heroku container:release web -a nickjenkins

```

## Contributors

* [Nick Jenkins](https://www.ndjenkins.com) - Data Scientist, API & Web dev, Team lead, Writer

See [CONTRIBUTING.md](CONTRIBUTING.md) in Github repo for specific instructions on contributing to project.

Usage rights governed by [LICENSE](LICENSE) in Github repo or page footer.