Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1ff450c
fix naming
rustbas Jun 5, 2025
ac5abef
dont run pipeline on push
rustbas Jun 5, 2025
ed96af5
fix network name
rustbas Jun 5, 2025
d9ca6a3
todo
rustbas Jun 5, 2025
487f714
add local network
rustbas Jun 6, 2025
7942dc7
fix env
rustbas Jun 6, 2025
e5e2c10
remove fake job
rustbas Jun 6, 2025
9d33e8c
add saccada host
rustbas Jun 6, 2025
5201203
add db name to postgres
rustbas Jun 6, 2025
9ada62f
mount instead copy
rustbas Jun 6, 2025
0a8bd3e
don't need a rebuild docker if files not touched
rustbas Jun 6, 2025
a41a37b
fix compose
rustbas Jun 6, 2025
1c9f69e
set debug to False
rustbas Jun 6, 2025
f81388e
make migrations in docker-entrypoint
rustbas Jun 6, 2025
ba83844
fix naming
rustbas Jun 6, 2025
c336908
remove paths
rustbas Jun 6, 2025
a9df789
add trusted origins
rustbas Jun 6, 2025
6b4e126
init Jenkinsfile
rustbas Jun 9, 2025
92498c0
init ssh command
rustbas Jun 9, 2025
0169c28
make new ssh
rustbas Jun 9, 2025
ef2741f
add colons
rustbas Jun 9, 2025
df31f46
add port
rustbas Jun 9, 2025
1a3bfca
privcacy fixes
rustbas Jun 9, 2025
a0dd1e9
fix
rustbas Jun 9, 2025
3593e52
fix
rustbas Jun 9, 2025
90d5d05
test
rustbas Jun 9, 2025
316ab86
test 2
rustbas Jun 9, 2025
ebe164c
add docker compose step
rustbas Jun 9, 2025
5674895
fix typo
rustbas Jun 9, 2025
ab4016a
test EOF
rustbas Jun 9, 2025
408d9d7
fix
rustbas Jun 9, 2025
927985d
add bash
rustbas Jun 9, 2025
3dffd85
_EOF_
rustbas Jun 9, 2025
5ba1fcc
test
rustbas Jun 9, 2025
bc8f4a5
quote EOF
rustbas Jun 9, 2025
0806e2f
test
rustbas Jun 9, 2025
28a2772
try this
rustbas Jun 9, 2025
9cb3191
full pipeline
rustbas Jun 9, 2025
a2e446c
add jenkins manual deploy
rustbas Jun 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: CI-pipeline
on:
workflow_dispatch:
push:
branches:
- dev

pull_request:
branches:
- main
types:
- opened

jobs:
linters:
Expand Down Expand Up @@ -57,9 +55,6 @@ jobs:
Repository: ${{ github.repository }}
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}

- name: Check fail
run: echo "Unreachable"

- name: Notify in telegram about success
uses: appleboy/telegram-action@master
with:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/jenkins-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Deploy on server
on:
workflow_dispatch:

jobs:
Deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Trigger Jenkins jobs
uses: appleboy/jenkins-action@master
with:
url: "http://ci.saccada.xyz"
user: ${{ env.JENKINS_USERNAME }}
token: ${{ secrets.JENKINS_TOKEN }}
job: "Deploy Django application"
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY ./mysite ./mysite
COPY ./polls ./polls
COPY ./manage.py .

RUN ./manage.py makemigrations
# RUN ./manage.py migrate

COPY docker-entrypoint.sh .
Expand Down
36 changes: 36 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pipeline {
agent any


stages {
stage('Hello') {
steps {
echo 'Hello from Jenkins'
}
}
stage('Connect to server') {
steps {
withCredentials([
sshUserPrivateKey(
credentialsId: '73d234d2-3f9d-44e9-97fc-b6317070b462',
keyFileVariable: 'SSH_PRIVATE_KEY'
)
]) {
sh '''#!/bin/bash
ssh -i "$SSH_PRIVATE_KEY" -p 2222 saccada@saccada.xyz << EOF
cd ~/ws/django-example-app
git pull --rebase
docker compose pull
docker compose down
docker compose up -d
'''
}
}
}
}
post {
always {
sleep 5
}
}
}
26 changes: 20 additions & 6 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
services:
app:
container_name: wtukatyr/django-example-app:latest
django-app:
image: wtukatyr/django-example-app:latest
container_name: django-app
ports:
- "8989:8000"
depends_on:
- db
volumes:
- ./mysite:/app/mysite
- ./polls:/app/polls
environment:
DATABASE_NAME: ${DATABASE_NAME}
DATABASE_USERNAME: ${DATABASE_USERNAME}
Expand All @@ -14,7 +18,9 @@ services:
env_file:
- .env
networks:
- proxy-common
- django_app_network
- proxy_common

db:
image: postgres:14
restart: always
Expand All @@ -30,13 +36,21 @@ services:
volumes:
- pg-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: sa
POSTGRES_PASSWORD: example
POSTGRES_PORT: 5432
POSTGRES_DB: ${DATABASE_NAME}
POSTGRES_USER: ${DATABASE_USERNAME}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_PORT: ${DATABASE_PORT}
env_file:
- .env
networks:
- django_app_network
- proxy_common

volumes:
pg-data:

networks:
django_app_network:
name: django_app_network
proxy_common:
external: true
3 changes: 3 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
echo "Collect static files"
python manage.py collectstatic --noinput


# Apply database migrations
echo "Make migrations"
RUN ./manage.py makemigrations
echo "Apply database migrations"
python manage.py migrate

Expand Down
5 changes: 3 additions & 2 deletions mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False

ALLOWED_HOSTS = ["localhost"]
CSRF_TRUSTED_ORIGINS = ["https://app.saccada.xyz"]
ALLOWED_HOSTS = ["localhost", "app.saccada.xyz"]


# Application definition
Expand Down
Loading