-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Development
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Docker Image CI/CD | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
# Calculate new version number | ||
- name: Calculate new version number | ||
run: echo "NEW_VERSION=$(python scripts/calculate_version.py)" >> $GITHUB_ENV | ||
|
||
# Log in to DockerHub | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} # Change this in you GITHUB secrets | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} # Change this in you GITHUB secrets | ||
|
||
# Build and push the Docker image | ||
- name: Build and Push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: robounord/uptime-kuma-rest:${{ env.NEW_VERSION }} # Change this to your DockerHub username and image name | ||
|
||
# Update docker-compose.yml and version.txt (comment docker-compose.yml out if you don't use it) | ||
- name: Update docker-compose.yml and version.txt | ||
if: success() | ||
run: | | ||
python scripts/update_docker_compose.py ${{ env.NEW_VERSION }} || exit 1 | ||
python scripts/update_version_txt.py || exit 1 | ||
git config user.name github-actions || exit 1 | ||
git config user.email [email protected] || exit 1 | ||
git add docker-compose.yml version.txt || exit 1 | ||
git commit -m "Update docker-compose and version.txt with new image version ${{ env.NEW_VERSION }}" || exit 1 | ||
git push || exit 1 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.12 | ||
|
||
# Set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV DJANGO_SETTINGS_MODULE=uptime_kuma_rest.settings | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
gcc \ | ||
default-libmysqlclient-dev \ | ||
&& apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the current directory contents into the container at /app | ||
COPY . . | ||
|
||
# Install any needed packages specified in requirements.txt | ||
RUN pip install --upgrade pip | ||
RUN pip install --upgrade cython | ||
RUN pip install -r requirements.txt | ||
RUN pip install gunicorn | ||
|
||
# Make port 8000 available to the world outside this container | ||
EXPOSE 8000 | ||
|
||
# Run gunicorn | ||
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "uptime_kuma_rest:application"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AuthenticateAppConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'authenticate_app' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from django.contrib.auth.forms import UserCreationForm, UserChangeForm, PasswordChangeForm, AdminPasswordChangeForm | ||
from django.contrib.auth.models import User | ||
from django import forms | ||
|
||
class ChangePasswordForm(PasswordChangeForm): | ||
class Meta: | ||
model = User | ||
fields = ('old_password', 'new_password1', 'new_password2',) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(ChangePasswordForm, self).__init__(*args, **kwargs) | ||
|
||
self.fields['old_password'].widget.attrs['class'] = 'form-control' | ||
self.fields['old_password'].widget.attrs['placeholder'] = 'Indtast din nuværende adgangskode' | ||
self.fields['old_password'].label = '' | ||
self.fields['new_password1'].widget.attrs['class'] = 'form-control' | ||
self.fields['new_password1'].label = '' | ||
self.fields['new_password1'].widget.attrs['placeholder'] = 'Ny adgangskode' | ||
self.fields[ | ||
'new_password1'].help_text = '<div class="form-text text-muted"><small><ul><li>Din adgangskode kan ikke være for ens med dine andre personlige oplysninger.</li><li>Din adgangskode skal indeholde mindst 8 tegn.</li><li>Din adgangskode kan ikke være en typisk brugt adgangskode.</li><li>Din adgangskode kan ikke bestå udelukkende af tal.</li></ul></small></div>' | ||
|
||
self.fields['new_password2'].widget.attrs['class'] = 'form-control' | ||
self.fields['new_password2'].widget.attrs['placeholder'] = 'Gentag adgangskode' | ||
self.fields[ | ||
'new_password2'].help_text = '<div class="form-text text-muted"><small>Indtast den samme nye adgangskode som før til bekræftelse.</small></div>' | ||
self.fields['new_password2'].label = '' | ||
|
||
class EditProfileForm(UserChangeForm): | ||
password = forms.CharField(label="", widget=forms.TextInput( | ||
attrs={'type': 'hidden', })) | ||
email = forms.EmailField(label="Email", | ||
widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Indtast email'})) | ||
first_name = forms.CharField(label="Fornavn", max_length=100, widget=forms.TextInput( | ||
attrs={'class': 'form-control', 'placeholder': 'Indtast fornavn'})) | ||
last_name = forms.CharField(label="Efternavn", max_length=100, widget=forms.TextInput( | ||
attrs={'class': 'form-control', 'placeholder': 'Indtast efternavn'})) | ||
|
||
class Meta: | ||
model = User | ||
fields = ('username', 'first_name', 'last_name', 'email', 'password',) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(EditProfileForm, self).__init__(*args, **kwargs) | ||
|
||
self.fields['username'].widget.attrs['class'] = 'form-control' | ||
self.fields['username'].widget.attrs['placeholder'] = 'Indtast brugernavn' | ||
self.fields['username'].help_text = '<div class="form-text text-muted"><small>Påkrævet. 150 tegn eller færre. Kun bogstaver, cifre og @ /. / + / - / _.</small></div>' | ||
self.fields['username'].label = 'Brugernavn' | ||
|
||
|
||
class SignUpForm(UserCreationForm): | ||
email = forms. EmailField(label="", widget=forms.TextInput(attrs={'class':'form-control', 'placeholder': 'Indtast email'})) | ||
first_name = forms.CharField(label="", max_length=100, widget=forms.TextInput(attrs={'class':'form-control', 'placeholder': 'Indtast fornavn'})) | ||
last_name = forms.CharField(label="", max_length=100, widget=forms.TextInput(attrs={'class':'form-control', 'placeholder': 'Indtast efternavn'})) | ||
|
||
|
||
class Meta: | ||
model = User | ||
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 'password2',) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(SignUpForm, self).__init__(*args, **kwargs) | ||
|
||
self.fields['username'].widget.attrs['class'] = 'form-control' | ||
self.fields['username'].widget.attrs['placeholder'] = 'Indtast brugernavn' | ||
self.fields['username'].help_text = '<div class="form-text text-muted"><small>Påkrævet. 150 tegn eller færre. Kun bogstaver, cifre og @ /. / + / - / _.</small></div>' | ||
self.fields['username'].label = '' | ||
self.fields['password1'].widget.attrs['class'] = 'form-control' | ||
self.fields['password1'].widget.attrs['placeholder'] = 'Indtast adgangskode' | ||
self.fields['password1'].help_text = '<div class="form-text text-muted"><small>Din adgangskode kan ikke være for ens med dine andre personlige oplysninger.<ul><li>Din adgangskode skal indeholde mindst 8 tegn.</li><li>Din adgangskode kan ikke være en almindelig adgangskode.</li><li>Din adgangskode kan ikke være helt numerisk.</li></ul></small></div>' | ||
self.fields['password1'].label = '' | ||
self.fields['password2'].widget.attrs['class'] = 'form-control' | ||
self.fields['password2'].widget.attrs['placeholder'] = 'Gentag adgangskode' | ||
self.fields['password2'].help_text = '<div class="form-text text-muted"><small>Indtast den samme adgangskode som før til bekræftelse.</small></div>' | ||
self.fields['password2'].label = '' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% extends 'base.html' %} | ||
{% block title %}U/Nord elev evaluering | Skift din adgangskode{% endblock %} | ||
{% block content %} | ||
<div class="col-6 col-md-4 offset-md-3"> | ||
<h2> | ||
Skift din adgangskode | ||
</h2> | ||
<form method="POST" action="{% url 'change_password' %}"> | ||
{% csrf_token %} | ||
{% if form.errors %} | ||
<div class="alert alert-danger alert-dismissible fade show" role="alert"> | ||
<p> Der er fejl i formen</p> | ||
<button type="button" class="btn-close" data-bs-dismiss="alert" | ||
aria-label="Close"></button> | ||
</div> | ||
{% endif %} | ||
{{ form.as_p }} | ||
<button type="submit" class="btn btn-secondary">Skift din adgangskode</button> | ||
</form> | ||
<br/><br/> | ||
<div class="alert alert-primary" role="alert"> | ||
Du bliver logget ud efter du skifter adgangskode | ||
</div> | ||
|
||
</div> | ||
|
||
|
||
|
||
|
||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends 'base.html' %} | ||
{% block title %}U/Nord elev evaluering | Rediger profil info{% endblock %} | ||
{% block content %} | ||
<div class="col-6 col-md-4 offset-md-3"> | ||
<h2>Reiger profil info</h2> | ||
<form method="POST" action="{% url 'edit_profile' %}"> | ||
{% csrf_token %} | ||
{% if form.errors %} | ||
<div class="alert alert-danger alert-dismissible fade show" role="alert"> | ||
<p> Der er fejl i formen</p> | ||
<button type="button" class="btn-close" data-bs-dismiss="alert" | ||
aria-label="Close"></button> | ||
</div> | ||
{% endif %} | ||
{{ form.as_p }} | ||
<button type="submit" class="btn btn-secondary">Opdater profil info</button> | ||
</form> | ||
</div> | ||
|
||
|
||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% extends 'base.html' %} | ||
{% block title %}U/Nord elev evaluering | Login{% endblock %} | ||
{% block content %} | ||
|
||
|
||
<div class="col-6 col-md-4 offset-md-3"> | ||
<h2>Login</h2> | ||
<form method="post"> | ||
{% csrf_token %} | ||
<div class="mb-3"> | ||
<input type="text" class="form-control" placeholder="Indtast brugernavn" name="username"> | ||
</div> | ||
<div class="mb-3"> | ||
<input type="password" class="form-control" placeholder="Indtast Adgangskode" name="password"> | ||
</div> | ||
|
||
<button type="submit" class="btn btn-secondary">Login</button> | ||
</form> | ||
<br/> | ||
{% if messages %} | ||
<div class="alert alert-danger alert-dismissible fade show" role="alert"> | ||
Forkert brugernavn og / eller adgangskode eller du er blevet logget ud | ||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endblock %} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends 'base.html' %} | ||
{% block title %}U/Nord elev evaluering| Registrer burger{% endblock %} | ||
{% block content %} | ||
<div class="col-6 col-md-4 offset-md-3"> | ||
<h2>Registrer profil info</h1> | ||
<form method="POST" action="{% url 'register_user' %}"> | ||
{% csrf_token %} | ||
{% if form.errors %} | ||
<div class="alert alert-danger alert-dismissible fade show" role="alert"> | ||
<p> Der er fejl i formen</p> | ||
<button type="button" class="btn-close" data-bs-dismiss="alert" | ||
aria-label="Close"></button> | ||
</div> | ||
{% endif %} | ||
{{ form.as_p }} | ||
<button type="submit" class="btn btn-secondary">Register bruger</button> | ||
</form> | ||
</div> | ||
|
||
|
||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""djangoProject URL Configuration | ||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/3.2/topics/http/urls/ | ||
Examples: | ||
Function views | ||
1. Add an import: from my_app import views | ||
2. Add a URL to urlpatterns: path('', views.home, name='home') | ||
Class-based views | ||
1. Add an import: from other_app.views import Home | ||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') | ||
Including another URLconf | ||
1. Import the include() function: from django.urls import include, path | ||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) | ||
""" | ||
|
||
from django.urls import path | ||
from . import views | ||
|
||
app_name = 'authenticate_app' | ||
|
||
urlpatterns = [ | ||
path('login/', views.login_user, name='login'), | ||
path('logout/', views.logout_user, name='logout'), | ||
path('register_user/', views.register_user, name='register_user'), | ||
path('edit_profile/', views.edit_profile, name='edit_profile'), | ||
path('change_password/', views.change_password, name='change_password'), | ||
|
||
] |