-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
708 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
name: "[Feature] 작업할 내용" | ||
about: "✨ Feat Issue" | ||
title: "[Feature]" | ||
labels: feature | ||
assignees: '' | ||
|
||
--- | ||
|
||
### 🌿 Feature | ||
(기능 설명) | ||
|
||
### ✅ To-Do List | ||
- [ ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## 🎵 Issue | ||
|
||
close #이슈번호 | ||
|
||
## 🔨 작업 내용 | ||
|
||
|
||
## 📩 API Test | ||
|
||
|
||
## ➰ ETC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Deploy to EC2 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@master | ||
|
||
- name: create env file | ||
run: | | ||
touch .env | ||
echo "${{ secrets.ENV_VARS }}" >> .env | ||
- name: create remote directory | ||
uses: appleboy/ssh-action@v0.1.4 | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.KEY }} | ||
script: mkdir -p /home/ubuntu/srv/ubuntu | ||
|
||
- name: copy source via ssh key | ||
uses: burnett01/rsync-deployments@4.1 | ||
with: | ||
switches: -avzr --delete | ||
remote_path: /home/ubuntu/srv/ubuntu/ | ||
remote_host: ${{ secrets.HOST }} | ||
remote_user: ubuntu | ||
remote_key: ${{ secrets.KEY }} | ||
|
||
- name: executing remote ssh commands using password | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.KEY }} | ||
script: | | ||
sh /home/ubuntu/srv/ubuntu/config/scripts/deploy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM python:3.8.3-alpine | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
# dependencies for psycopg2-binary | ||
RUN apk add --no-cache mariadb-connector-c-dev | ||
RUN apk update && apk add python3 python3-dev mariadb-dev build-base && pip3 install mysqlclient==2.2.4 && apk del python3-dev mariadb-dev build-base | ||
|
||
|
||
# By copying over requirements first, we make sure that Docker will cache | ||
# our installed requirements rather than reinstall them on every build | ||
RUN apk update && apk add libpq | ||
RUN apk update \ | ||
&& apk add --virtual build-deps gcc python3-dev musl-dev \ | ||
&& apk add --no-cache jpeg-dev zlib-dev mariadb-dev | ||
COPY requirements.txt /app/requirements.txt | ||
RUN pip install -r requirements.txt | ||
RUN apk del jpeg-dev zlib-dev | ||
|
||
# Now copy in our code, and run it | ||
COPY . /app/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# BUILDER # | ||
########### | ||
|
||
# pull official base image | ||
FROM python:3.8.3-alpine as builder | ||
|
||
# set work directory | ||
WORKDIR /usr/src/app | ||
|
||
|
||
# set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# install psycopg2 dependencies | ||
RUN apk update && apk add python3 python3-dev mariadb-dev build-base && pip3 install mysqlclient | ||
|
||
# dependencies for pillow | ||
RUN apk add --no-cache jpeg-dev zlib-dev | ||
RUN apk add --no-cache --virtual .build-deps build-base linux-headers | ||
|
||
# install dependencies | ||
COPY ./requirements.txt . | ||
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt | ||
|
||
|
||
######### | ||
# FINAL # | ||
######### | ||
|
||
# pull official base image | ||
FROM python:3.8.3-alpine | ||
|
||
# create directory for the app user | ||
RUN mkdir -p /home/app | ||
|
||
# create the app user | ||
RUN addgroup -S app && adduser -S app -G app | ||
|
||
# create the appropriate directories | ||
ENV HOME=/home/app | ||
ENV APP_HOME=/home/app/web | ||
RUN mkdir $APP_HOME | ||
RUN mkdir $APP_HOME/static | ||
RUN mkdir $APP_HOME/media | ||
WORKDIR $APP_HOME | ||
|
||
# install dependencies | ||
RUN apk update && apk add libpq tzdata | ||
RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime | ||
RUN apk update \ | ||
&& apk add --virtual build-deps gcc python3-dev musl-dev \ | ||
&& apk add --no-cache jpeg-dev zlib-dev mariadb-dev | ||
COPY --from=builder /usr/src/app/wheels /wheels | ||
COPY --from=builder /usr/src/app/requirements.txt . | ||
RUN pip install mysqlclient | ||
RUN pip install --no-cache /wheels/* | ||
RUN apk del build-deps | ||
|
||
# set timezone | ||
ENV TZ=Asia/Seoul | ||
|
||
# copy entrypoint-prod.sh | ||
COPY ./config/docker/entrypoint.prod.sh $APP_HOME | ||
|
||
# copy project | ||
COPY . $APP_HOME | ||
|
||
# chown all the files to the app user | ||
RUN chown -R app:app $APP_HOME | ||
|
||
# change to the app user | ||
USER app |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BlogConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "blog" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 4.2.7 on 2024-09-05 03:39 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Blog", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("title", models.CharField(max_length=20)), | ||
("content", models.TextField()), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.db import models | ||
|
||
class Blog(models.Model): | ||
title = models.CharField(max_length=20) | ||
content = models.TextField() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from rest_framework import serializers | ||
from .models import * | ||
|
||
class BlogSerializer (serializers.ModelSerializer): | ||
class Meta: | ||
model = Blog | ||
fields = '__all__' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.urls import path | ||
from .views import * | ||
|
||
app_name = 'blog' | ||
|
||
urlpatterns = [ | ||
path('', BlogDetailView.as_view()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django.shortcuts import render | ||
from rest_framework import views | ||
from .models import Blog | ||
from .serializers import * | ||
from rest_framework.response import Response | ||
from rest_framework.status import * | ||
|
||
|
||
# Create your views here. | ||
|
||
|
||
class BlogDetailView(views.APIView): | ||
def get(self, request): | ||
blogs=Blog.objects.all() | ||
serializers=BlogSerializer(blogs,many=True) | ||
return Response({'message':'화이팅~!','data': serializers.data}, status=HTTP_200_OK) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for blogProject project. | ||
It exposes the ASGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blogProject.settings") | ||
|
||
application = get_asgi_application() |
Oops, something went wrong.