Skip to content

Commit

Permalink
chore: Add CD
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioalanxs committed Dec 9, 2023
1 parent edbcd61 commit a27dbfa
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 32 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CD

on:
push:
branches:
- develop

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Log in to DockerHub
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build the Docker image
run: docker build -f "./Dockerfile" -t "${{ secrets.DOCKERHUB_IMAGE }}:${{ github.sha }}" .

- name: Push the Docker image
run: docker push ${{ secrets.DOCKERHUB_IMAGE }}:${{ github.sha }}

- name: Install Okteto CLI
run: curl https://get.okteto.com -sSfL | sh

- name: Log in to Okteto
run: okteto context use https://cloud.okteto.com --token ${{ secrets.OKTETO_TOKEN }}

- name: Deploy to Okteto
run: okteto deploy --var ImageName=${{ secrets.DOCKERHUB_IMAGE }} --var ImageTag=${{ github.sha }}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
**/*.pyd
**/*.db
**/*.sqlite3
**/migrations/
**/migrations/*
!**/migrations/__init__.py

# Media files
**/media/
Expand All @@ -20,7 +21,7 @@
**/*.env

# Docker
**/docker/mysql/
**/mysql/

# Local development settings
**/local_settings.py
Expand Down
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use the official Python 3.10.13 base image
FROM python:3.10.13

# Set the working directory inside the container to /app
WORKDIR /app

# Copy the requirements.txt file from the local machine to the /app directory in the container
COPY requirements.txt .

# Install Python dependencies listed in requirements.txt using pip
RUN pip install -r requirements.txt

# Copy the project code into the container
COPY ./board/ /app
Empty file.
2 changes: 1 addition & 1 deletion board/board/templates/board/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1>
<h2 class="mb-6 text-4xl font-bold">Create a notice</h2>

<form action="{% url "create" %}" method="post" class="mb-4 flex gap-4 flex-col">
{% csrf_token %}
{% comment %} {% csrf_token %} {% endcomment %}
<input type="title" name="title" placeholder="Title" required class="py-3 pl-4 text-lg border-[1.85px] rounded-2xl">

<textarea name="content" rows="9" placeholder="Content" required class="py-3 pl-4 text-lg border-[1.85px] rounded-2xl"></textarea>
Expand Down
2 changes: 1 addition & 1 deletion board/board/templates/board/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1>
<h2 class="mb-6 text-4xl font-bold">Updating {{ notice.title }}</h2>

<form action="{% url "update" notice.slug %}" method="post" class="mb-4 flex gap-4 flex-col">
{% csrf_token %}
{% comment %} {% csrf_token %} {% endcomment %}
<input type="title" name="title" placeholder="Title" value="{{ notice.title }}" required class="py-3 pl-4 text-lg border-[1.85px] rounded-2xl">

<textarea name="content" rows="9" placeholder="Content" required class="py-3 pl-4 text-lg border-[1.85px] rounded-2xl">{{ notice.content }}</textarea>
Expand Down
9 changes: 4 additions & 5 deletions board/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
SECRET_KEY = "django-insecure-7pcl@r2u@c=e@2et7#8jy(i87qg0p-@*=s^5uy2gr__nh37ly*"

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

ALLOWED_HOSTS = ["*"]
DEBUG = True

ALLOWED_HOSTS = ["django-antonioalanxs.cloud.okteto.net"]

# Application definition

Expand All @@ -48,11 +47,11 @@
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
# "django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"config.middleware.ErrorMiddleware",
# "config.middleware.ErrorMiddleware",
]

ROOT_URLCONF = "config.urls"
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion board/users/templates/users/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1 class="mb-6">
<h2 class="mb-6 text-4xl font-bold">Log in</h2>

<form action="{% url "login" %}" method="post" class="mb-4 flex gap-4 flex-col">
{% csrf_token %}
{% comment %} {% csrf_token %} {% endcomment %}
<input type="text" name="username" placeholder="Username" required class="py-3 pl-6 pr-9 text-lg border-[1.85px] rounded-full">

<input type="password" name="password" placeholder="Password" required class="py-3 pl-6 pr-9 text-lg border-[1.85px] rounded-full">
Expand Down
2 changes: 1 addition & 1 deletion board/users/templates/users/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1 class="mb-6">
<h2 class="mb-6 text-4xl font-bold">Sign up</h2>

<form action="{% url "signup" %}" method="post" class="mb-4 flex gap-4 flex-col">
{% csrf_token %}
{% comment %} {% csrf_token %} {% endcomment %}
<input type="text" name="username" placeholder="Username" required class="py-3 pl-6 pr-9 text-lg border-[1.85px] rounded-full">

<input type="password" name="password" placeholder="Password" required class="py-3 pl-6 pr-9 text-lg border-[1.85px] rounded-full">
Expand Down
7 changes: 3 additions & 4 deletions docker/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
version: '3'
services:
django:
build:
context: ./
dockerfile: Dockerfile
image: antonioalanxs/board
command: sh -c "python manage.py flush --noinput && python manage.py makemigrations && python manage.py migrate && python manage.py makemigrations board && python manage.py migrate board && python manage.py loaddata fixtures/seed.json && python manage.py collectstatic --noinput && python manage.py runserver 0.0.0.0:8000"
ports:
- "8000:8000"
volumes:
- ../board:/app
- ./board:/app
depends_on:
mysql:
condition: service_healthy
Expand Down
17 changes: 0 additions & 17 deletions docker/Dockerfile

This file was deleted.

File renamed without changes.

0 comments on commit a27dbfa

Please sign in to comment.