Skip to content

Commit

Permalink
feat: full rewrite of application (#48)
Browse files Browse the repository at this point in the history
* misc: trigger release

* misc(deps): update dependencies (#41)

* misc: rewrite (#43)

* misc(repo): rebrand the project as central-command

* feat(repo)!: first stone of the rewrite

* feat(repo): feature parity with last attempt

* misc: linter

* misc: get rid of useless env for creating directories

* misc: get rid of commented line in docker-compose.yml

* misc: use Bob's email as example

* feat: add is_active field to admin view for accounts

* feat: improve models by adding help text instead of obscure comments

* fix: fixes username validation doing literally nothing

* misc: migration update

* misc: rewrite continuation (#47)

* fix: make public account data actually public

* feat: readd needed html templates

* fix: accounts that change their email will now have to confirm the new email

* feat: attempting to log in before confirmation will now raise and explain the issue

* feat: writing data to other-data will now only update keys if present or append new data if not.
We also won't need a create endpoint anymore, since write will do it if the record doesn't previously exist.

* feat: load environmental variables from a .env file with python-dotenv

* feat: adds account verification endpoint for game servers
  • Loading branch information
corp-0 authored Feb 7, 2022
1 parent 77ed120 commit 4807277
Show file tree
Hide file tree
Showing 64 changed files with 1,095 additions and 982 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- "v*"

env:
IMAGE_NAME: unitystation/unitystation_auth
IMAGE_NAME: unitystation/central-command

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
needs: [release]
env:
IMAGE_NAME: unitystation/unitystation_auth
IMAGE_NAME: unitystation/central-command
steps:
- uses: actions/checkout@v2
with:
Expand Down
24 changes: 16 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,19 @@ RUN apk add --no-cache libpq \

COPY src .

RUN addgroup -S unitystation \
&& adduser -S auth_server -G unitystation \
&& chown -R auth_server:unitystation /src

USER auth_server

ENTRYPOINT ["python", "manage.py"]
CMD ["runserver", "0:8000"]
RUN mkdir /home/website
RUN mkdir /home/website/statics
RUN mkdir /home/website/media

# I'm too dumb to make user permissions over shared volumes work
#RUN addgroup -S unitystation \
# && adduser -S central_command -G unitystation \
# && chown -R central_command:unitystation /src \
# && chown -R central_command:unitystation $home
#
#USER central_command

RUN sed -i 's/\r$//g' entrypoint.sh
RUN chmod +x entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# unitystation_auth
![Docker Image Version (latest by date)](https://img.shields.io/docker/v/unitystation/unitystation_auth)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/38cce37d4c854ca48645fd5ecc9cae61)](https://www.codacy.com/gh/unitystation/unitystation_auth/dashboard?utm_source=github.com&utm_medium=referral&utm_content=unitystation/unitystation_auth&utm_campaign=Badge_Grade)
# Central Command
![Docker Image Version (latest by date)](https://img.shields.io/docker/v/unitystation/central-command?sort=date)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/38cce37d4c854ca48645fd5ecc9cae61)](https://www.codacy.com/gh/unitystation/central-command/dashboard?utm_source=github.com&utm_medium=referral&utm_content=unitystation/central-command&utm_campaign=Badge_Grade)

The all-in-one backend application for [Unitystation](https://github.com/unitystation/unitystation)

### Features
- Account managment and user validation.
- Server list managment.
- In-game persistence.
- Works cross-fork!
- Modular architecture.

### Development guide
#### Setting up Docker
Expand Down
20 changes: 7 additions & 13 deletions dev-compose.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
version: "3"

x-django-defaults: &django_defaults
build: .
env_file: ./.env

services:
db:
image: postgres
image: postgres:14.1-alpine
environment:
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- db-data:/var/lib/postgresql/data
ports:
- "5432:5432"

web_migration:
<<: *django_defaults
command: migrate
depends_on:
- db

web:
<<: *django_defaults
depends_on:
- web_migration
- db
build: .
env_file: ./.env
ports:
- "8000:8000"
volumes:
- ./src:/src
command: python manage.py runserver 0.0.0.0:8000

volumes:
db-data:
static-volume:
media-volume:
36 changes: 22 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
version: "3"

x-django-defaults: &django_defaults
image: unitystation/unitystation_auth
env_file: ./.env
x-common-volumes: &common-volumes
volumes:
- static-volume:/home/website/statics
- media-volume:/home/website/media

services:
db:
image: postgres
image: postgres:14.1-alpine
environment:
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- db-data:/var/lib/postgresql/data

web_migration:
<<: *django_defaults
command: migrate
depends_on:
- db

web:
<<: *django_defaults
depends_on:
- web_migration
image: unitystation/central-command:latest
environment:
- DEBUG=0
env_file: ./.env
expose:
- 8000
command: gunicorn central-command.wsgi:application --bind 0.0.0.0:8000
<<: *common-volumes

nginx:
build: ./nginx
ports:
- "8000:8000"
- 80:80
depends_on:
- web
<<: *common-volumes

volumes:
db-data:
static-volume:
media-volume:
11 changes: 8 additions & 3 deletions example.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_HOST_USER=me@gmail.com
EMAIL_HOST_USER=bob@example.com
EMAIL_HOST_PASSWORD=password
EMAIL_PAGE_DOMAIN=http://mydomain.com/
SECRET_KEY=MYSECRET
EMAIL_PAGE_DOMAIN=http://localhost:8000
SECRET_KEY=MYSECRET
DEBUG=1
DB_ENGINE=django.db.backends.postgresql
DB_NAME=postgres
DB_HOST=db
DB_PORT=5432
7 changes: 7 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM nginx:1.21-alpine

RUN rm /etc/nginx/conf.d/default.conf
RUN mkdir /home/website
RUN mkdir /home/website/statics
RUN mkdir /home/website/media
COPY nginx.conf /etc/nginx/conf.d
24 changes: 24 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
upstream central_command {
server web:8000;
}

server {

listen 80;

location / {
proxy_pass http://central_command;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
client_max_body_size 100M;
}

location /static/ {
alias /home/website/statics/;
}

location /media/ {
alias /home/website/media/;
}
}
Loading

0 comments on commit 4807277

Please sign in to comment.