Skip to content

Commit

Permalink
Merge pull request #72 from OZ-Coding-School/feat/database_edit
Browse files Browse the repository at this point in the history
Feat/�develop edit
  • Loading branch information
youngkwangjoo authored Jul 31, 2024
2 parents 4967d0e + 54e1c3b commit b55e48c
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 25 deletions.
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 배포용

FROM python:3.11-alpine3.19

# LABEL 명령어는 이미지에 메타데이터를 추가합니다. 여기서는 이미지의 유지 관리자를 "dayeonkim"로 지정하고 있습니다.
Expand Down Expand Up @@ -39,3 +41,50 @@ USER django-user

# 이 명령어를 추가하여 pytest를 설치합니다.
RUN /py/bin/pip install pytest pytest-django


# 개발용

# FROM python:3.11-alpine3.19

# # LABEL 명령어는 이미지에 메타데이터를 추가합니다. 여기서는 이미지의 유지 관리자를 "dayeonkim"로 지정하고 있습니다.
# LABEL maintainer="frog"

# # 환경 변수 PYTHONUNBUFFERED를 1로 설정합니다.
# # 이는 Python이 표준 입출력 버퍼링을 비활성화하게 하여, 로그가 즉시 콘솔에 출력되게 합니다.
# # 이는 Docker 컨테이너에서 로그를 더 쉽게 볼 수 있게 합니다.
# ENV PYTHONUNBUFFERED 1


# # 로컬 파일 시스템의 requirements.txt 파일을 컨테이너의 /tmp/requirements.txt로 복사합니다.
# # 이 파일은 필요한 Python 패키지들을 명시합니다.
# COPY ./requirements.txt /tmp/requirements.txt
# COPY ./requirements.dev.txt /tmp/requirements.dev.txt
# COPY ./potato_project /app
# WORKDIR /app
# EXPOSE 8000

# ARG DEV=false

# RUN python -m venv /py && \
# /py/bin/pip install --upgrade pip && \
# /py/bin/pip install -r /tmp/requirements.txt && \
# apk add --update --no-cache postgresql-client jpeg-dev && \
# apk add --update --no-cache --virtual .tmp-build-deps \
# build-base postgresql-dev musl-dev zlib zlib-dev linux-headers && \
# if [ $DEV = "true" ]; \
# then /py/bin/pip install -r /tmp/requirements.dev.txt ; \
# fi && \
# rm -rf /tmp && \
# apk del .tmp-build-deps && \
# adduser \
# --disabled-password \
# --no-create-home \
# django-user

# ENV PATH="/py/bin:$PATH"

# USER django-user

# # 이 명령어를 추가하여 pytest를 설치합니다.
# RUN /py/bin/pip install pytest pytest-django
47 changes: 46 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 배포용

# version: "3.11"
services:
app:
Expand All @@ -19,6 +21,49 @@ services:
- DB_USER=${RDS_USERNAME}
- DB_PASSWORD=${RDS_PASSWORD}
env_file:
- .env
- .env


# 개발용

# # version: "3.11"
# services:
# app:
# build:
# context: .
# args:
# - DEV=true
# ports:
# - "8000:8000"
# - "3000:3000" # debugger
# volumes:
# - ./potato_project:/app
# command: >
# sh -c "python manage.py wait_for_db &&
# python manage.py makemigrations &&
# python manage.py migrate &&
# python -u manage.py runserver --noreload 0.0.0.0:8000"
# environment:
# - DB_HOST=${DB_HOST}
# - DB_NAME=${DB_NAME}
# - DB_USER=${DB_USER}
# - DB_PASSWORD=${DB_PASSWORD}
# - PYDEVD_DISABLE_FILE_VALIDATION=1
# env_file:
# - .env
# depends_on:
# - db


# db: # PostgreSQL Database
# image: postgres:16-alpine
# volumes:
# - ./data/db:/var/lib/postgresql/data
# environment:
# - POSTGRES_DB=${POSTGRES_DB}
# - POSTGRES_USER=${POSTGRES_USER}
# - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
# env_file:
# - .env


23 changes: 19 additions & 4 deletions potato_project/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,33 @@
# WSGI 애플리케이션 설정
WSGI_APPLICATION = "app.wsgi.application"

# 배포용

# 데이터베이스 설정
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"HOST": os.environ.get("DB_HOST"),
"NAME": os.environ.get("DB_NAME"),
"USER": os.environ.get("DB_USER"),
"PASSWORD": os.environ.get("DB_PASSWORD"),
"HOST": os.environ.get("RDS_HOSTNAME"),
"NAME": os.environ.get("RDS_DB_NAME"),
"USER": os.environ.get("RDS_USERNAME"),
"PASSWORD": os.environ.get("RDS_PASSWORD"),
"PORT": os.environ.get("RDS_PORT", 5432),
}
}

# 개발용

# # 데이터베이스 설정
# DATABASES = {
# "default": {
# "ENGINE": "django.db.backends.postgresql",
# "HOST": os.environ.get("DB_HOST"),
# "NAME": os.environ.get("DB_NAME"),
# "USER": os.environ.get("DB_USER"),
# "PASSWORD": os.environ.get("DB_PASSWORD"),
# }
# }

# 비밀번호 검증 설정
AUTH_PASSWORD_VALIDATORS = [
{
Expand Down
25 changes: 25 additions & 0 deletions potato_project/potato_types/migrations/0002_add_initial_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.db import migrations

def insert_initial_data(apps, schema_editor):
PotatoType = apps.get_model('potato_types', 'PotatoType')
PotatoType.objects.create(potato_name="levelOnePotato", potato_description="Can be obtained after level 1.")
PotatoType.objects.create(potato_name="levelTwoPotato", potato_description="Can be obtained after level 2.")
PotatoType.objects.create(potato_name="levelThreePotato", potato_description="Can be obtained after level 3.")
PotatoType.objects.create(potato_name="levelFourPotato", potato_description="Can be obtained after level 4.")
PotatoType.objects.create(potato_name="levelFivePotato", potato_description="Can be obtained after level 5.")
PotatoType.objects.create(potato_name="winterPotato", potato_description="Can be obtained by committing on Christmas Day.")
PotatoType.objects.create(potato_name="ghostPotato", potato_description="Can be obtained by committing on Halloween.")
PotatoType.objects.create(potato_name="crystalPotato", potato_description="Can be obtained by committing consecutively for a month.")
PotatoType.objects.create(potato_name="dirtyPotato", potato_description="Can be obtained if there are no commits for a month.")
PotatoType.objects.create(potato_name="greenPotato", potato_description="Can be obtained if there are no commits for 3 months.")
PotatoType.objects.create(potato_name="shPotato", potato_description="?")

class Migration(migrations.Migration):

dependencies = [
("potato_types", "0001_initial"), # "0001_initial"은 모델 생성 마이그레이션의 이름입니다.
]

operations = [
migrations.RunPython(insert_initial_data),
]

This file was deleted.

2 changes: 1 addition & 1 deletion potato_project/stacks/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Migration(migrations.Migration):
),
(
"name",
models.CharField(max_length=20, null=True, verbose_name="스택명"),
models.CharField(max_length=255, null=True, verbose_name="스택명"),
),
],
),
Expand Down
60 changes: 60 additions & 0 deletions potato_project/stacks/migrations/0002_add_initial_stacks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from django.db import migrations

def add_initial_stacks(apps, schema_editor):
Stack = apps.get_model('stacks', 'Stack')
stacks = [
# 프로그래밍 언어
"Python", "Java", "JavaScript", "TypeScript", "C++", "C#", "Ruby", "Go", "Rust", "Swift",
"Kotlin", "PHP", "Scala", "R", "Dart", "Lua", "Haskell", "Erlang", "Clojure", "F#",

# 백엔드 프레임워크
"Django", "Flask", "FastAPI", "Spring Boot", "Express.js", "Ruby on Rails", "ASP.NET Core",
"Laravel", "Symfony", "Phoenix", "Gin", "Echo", "Ktor", "Micronaut", "Quarkus", "NestJS",
"Strapi", "Koa.js", "Fastify", "Sails.js",

# 프론트엔드 프레임워크/라이브러리
"React", "Vue.js", "Angular", "Svelte", "Ember.js", "Backbone.js", "jQuery", "Preact",
"Solid.js", "Alpine.js", "Lit", "Stimulus", "Meteor", "Next.js", "Nuxt.js", "Gatsby",
"Gridsome", "Eleventy", "Astro", "Remix",

# 모바일 개발
"React Native", "Flutter", "Xamarin", "Ionic", "PhoneGap", "Cordova", "NativeScript",
"Kivy", "SwiftUI", "Jetpack Compose", "Unity",

# 데이터베이스
"PostgreSQL", "MySQL", "MongoDB", "SQLite", "Redis", "Cassandra", "Couchbase", "Oracle",
"Microsoft SQL Server", "MariaDB", "Elasticsearch", "Neo4j", "InfluxDB", "DynamoDB",
"Firestore", "Realm", "CockroachDB", "TimescaleDB", "RethinkDB", "ArangoDB",

# 클라우드 플랫폼
"AWS", "Google Cloud Platform", "Microsoft Azure", "Heroku", "DigitalOcean", "Linode",
"Vultr", "IBM Cloud", "Oracle Cloud", "Alibaba Cloud",

# DevOps 및 인프라
"Docker", "Kubernetes", "Jenkins", "GitLab CI/CD", "Travis CI", "CircleCI", "Ansible",
"Terraform", "Puppet", "Chef", "Vagrant", "Prometheus", "Grafana", "ELK Stack", "Nagios", "Zabbix",

# 버전 관리
"Git", "Mercurial", "SVN",

# API 및 통신
"REST API", "GraphQL", "gRPC", "WebSocket", "RabbitMQ", "Apache Kafka", "MQTT", "ZeroMQ",

# 프론트엔드 도구
"Webpack", "Babel", "Sass", "Less", "PostCSS", "Gulp", "Grunt", "Parcel", "Rollup", "Vite",

# 테스팅
"Jest", "Mocha", "Jasmine", "Selenium", "Cypress", "Puppeteer", "JUnit", "TestNG", "PyTest", "RSpec"
]
for stack in stacks:
Stack.objects.create(name=stack)

class Migration(migrations.Migration):

dependencies = [
('stacks', '0001_initial'),
]

operations = [
migrations.RunPython(add_initial_stacks),
]
2 changes: 1 addition & 1 deletion potato_project/stacks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class Stack(models.Model):
name = models.CharField(max_length=20, null=True, verbose_name="스택명")
name = models.CharField(max_length=255, null=True, verbose_name="스택명")

def __str__(self):
return self.name

0 comments on commit b55e48c

Please sign in to comment.