This application is currently intended as the minimum viable product for Geek.Zone members and n00bs to be able to manage their Geek.Zone membership. We will build it from there, but that's our target right now! We currently use a third party to do this, and while they are not a bad service per se, they do charge us for their services and do not do all the things we need them to do. Building it ourselves will not only mean that we get the system that we need, but also that those involved will learn new, transferrable skills and have some fun doing so.
Take a look at the original spec doc.
Here's what the front page looks like in light mode and in dark mode.
The easiest and fastest way to run the project without cluttering your machine is by using docker containers. However you should be able to setup this project on any operating system that supports Django. We have instructions for Ubuntu based linux distributions and for Windows 10. Both can be found below.
# Install Docker
sudo apt-get update
sudo apt-get install -y docker.io
# Configure docker to start on boot
sudo systemctl enable docker.service
# Manage Docker as a non-root user
sudo groupadd docker
sudo usermod -aG docker $USER
Log out of your session completely and then log back in
# Install docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Install command completion
sudo curl \
-L https://raw.githubusercontent.com/docker/compose/1.29.2/contrib/completion/bash/docker-compose \
-o /etc/bash_completion.d/docker-compose
source ~/.bashrc
Switch to Linux Containers
if Docker Desktop is set to Windows Containers.An .env.dev
file under the web
folder is already existing and provides environment variables to docker-compose. There are 2 docker-compose files in the project folder: docker-compose.yml
, to be used in the ci/cd or to just run the project, and docker-compose.dev.yml
, to be used for development purposes instead (see the Local Development
section).
Make sure Docker is running (Ubuntu: sudo systemctl restart docker.service
or service docker.service start
; Windows 10: run Powershell as administrator Start-Service 'Docker Desktop Service'
)
docker-compose up
(to run containers when the images are already present in the machine; if not existing they will be created)
docker-compose --build
(to build images for each service outlined in the docker-compose.dev.yml file)
docker-compose up --build
(to force to re-build images and run containers out of these images)
docker-compose ps
(from another terminal window, to check the status of each container created by docker-compose)
If you navigate to http://localhost:8000/memberships/register
in your browser you should see the app main page. You can press control-c in the terminal to exit docker-compose.
docker-compose down
(to delete the network and containers that docker-compose created)
This guide assumes that you can execute basic terminal commands. It also assumes that you have setup github with SSH keys.
Ubuntu 20.04 and above should come with a recent enough version of Python 3 for you to follow along with this guide. As of writing I am using Python 3.8.5.
First follow the instructions below for initial setup.
pip
by running the command sudo apt install python3-pip
python3 -m pip install virtualenv
. This tool allows us to install dependencies local to a project and not clutter your system.git clone git@github.com:geekzonehq/web.git
and change into that directory cd web
.python3 -m virtualenv env
. This will create a folder in the project called env
that will contain all of the project dependencies.source env/bin/activate
sudo apt-get install libpq-dev
pip install -r requirements.txt
sudo apt-get -y install postgresql
sudo systemctl enable postgresql
or service postgresql start
sudo su postgres
psql
\password postgres
exit
exit
cat <<EOF > web/.env
DEBUG=1
DATABASE_USER=postgres
DATABASE_NAME=postgres
DATABASE_HOST=localhost
DATABASE_PASSWORD=postgres
DATABASE_PORT=5432
EOF
python3 manage.py migrate
sudo apt-get install rabbitmq-server
sudo systemctl enable rabbitmq-server
or service rabbitmq-server start
celery -A web worker --loglevel=info
python3 manage.py runserver
. If you navigate to http://localhost:8000/memberships/register
in your browser you should now see the app. You can press control-c in the terminal to exit the server.After you have done the above subsequent setup is a lot simpler.
source env/bin/activate # You only need to do this if your virtual env is not already active
python manage.py runserver
If there are new changes to the database the runserver output will run you through the process of updating and running the migrations.
This guide assumes that you can execute basic terminal/Powershell commands. It also assumes that you have setup github with SSH keys. Currently the project needs some adjustments to run in Windows. Specifically the USER and PASSWORD variables for Postgres need either to be hard-coded in settings.py or passed through cli when running database migrations.
python
into a command prompt will open the correct page on the Microsoft store. This will also install the pip
package manager.pip install virtualenv
. This tool allows us to install dependencies local to a project and not clutter your system.git clone git@github.com:geekzonehq/web.git
and change into that directory cd web
.python -m virtualenv env
. This will create a folder in the project called env
that will contain all of the project dependencies.env\Scripts\activate.bat
services.msc
: scroll down to the postgres-service=name and start it if it is not already running. If the option to start the service is greyed out, configure Postgres to start on boot: right-click on the postgres-service-name, click on Properties
and set the Startup type
to Automatic
.
The same can be achieved by running as administrator a couple of Powershell commands:
Install-Module PostgreSQLCmdlets
Set-Service -Name "<<postgres-service-name>>" -Status running -StartupType automatic
echo "DEBUG=1
DATABASE_USER=postgres
DATABASE_NAME=postgres
DATABASE_HOST=localhost
DATABASE_PASSWORD=postgres
DATABASE_PORT=5432" | tee web/.env
pip install -r requirements.txt
python manage.py migrate
celery -A web worker --loglevel=info
python manage.py runserver
. If you navigate to http://localhost:8000/memberships/register
in your browser you should now see the app. You can press control-c in the terminal to exit the server.After you have done the above subsequent setup is a lot simpler.
env\Scripts\activate.bat # You only need to do this if your virtual env is not already active
python manage.py runserver
If there are new changes to the database the runserver output will run you through the process of updating and running the migrations.
RabbitMQ & Celery have been purposefully implemented in a way that allows them to be used in any part of the project. Equally, this also allows them to be used interactively in the Django Python shell.
sudo systemctl start rabbitmq-server
; Windows 10: run Powershell as administrator Start-Service RabbitMQ
)celery -A web worker --loglevel=info
python manage.py shell
from memberships import tasks, email
import celery
tasks.py
, such as
tasks.task_send_email("Bob", "weoifjefij@mailinator.com", "Hello world", "Just a test")
You will need the password if you want to send from an @geek.zone email address. Please contact
@JamesGeddes for this or configure your own testing email address in settings.py
.
All commands in this section can be run either in Docker containers or in the virtual environment.
The website currently uses Tailwind CSS to style the front end. Tailwind works by generating a stylesheet at theme/static/css/dist/styles.css
, using settings located in theme/static_src
(with base styles at theme/static_src/src/styles.scss
).
A development build of styles.css
already exists in the repository, containing all possible Tailwind base styles. Therefore, only install and run Tailwind if you plan on making changes to settings or base styles at theme/static_src
(or you want to generate a production build of styles.css
). You do not need to install and run Tailwind to make simple styling changes.
To test any changes in the code:
Run the project in docker-compose from docker-compose.dev.yml
:
docker-compose -f docker-compose.dev.yml up --build
From another terminal window, open a shell into the web
container:
docker exec -it web sh
Run the following commands to install and start tailwind or generate a production build of styles.css
:
python3 manage.py tailwind install
python3 manage.py tailwind start
python3 manage.py tailwind build
To leave the container's shell, type:
exit
You will need to ensure Node.js and NPM are installed on your system first - Node.js must be version 12.13.0 or higher.
Once that's done, run:
python manage.py tailwind install
You will need to run this command again if you ever upgrade Node.js.
When running the local server, run the following in a second terminal/command prompt:
python manage.py tailwind start
This will re-generate the development build of styles.css
, then watch for any changes made to files in theme/static_src
.
A production build of
styles.css
can be generated using the commandpython manage.py tailwind build
- this reduces the file to only the base styles that are actually being used.
If you want to use LiveReload to automatically refresh your web browser in response to file changes, run the following in another terminal/command prompt:
python manage.py livereload
Clearly, you can and should use which ever development tools you prefer. If you don't have a preference, we suggest trying,
Also, do join us on our Discord!
Simply run python manage.py test
.
We have found the circleci local cli tool to be very useful when making changes to the circle build locally. The errors can be a bit cryptic, but it's easier than debugging basic syntax issues from within the circleci console.
We try to be super informal, and we welcome all PRs. For full details, see CONTRIBUTING.
Geek.Zone is a member of the Open Source Initiative, so all our projects are published under GPLv3. Any contributions you make will be published under these provisions. See LICENSE.