From 6fd8966b80f6d117361c0f754686eaae449da05f Mon Sep 17 00:00:00 2001 From: sejokim Date: Sat, 23 Mar 2024 21:29:05 +0900 Subject: [PATCH] =?UTF-8?q?Build:=20postgreSQL=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/friends/migrations/0001_initial.py | 32 --- backend/games/migrations/0001_initial.py | 88 ------- .../games/migrations/0002_game_started_at.py | 18 -- .../migrations/0003_casualgamelistview.py | 25 -- backend/src/settings.py | 30 +-- backend/users/migrations/0001_initial.py | 36 --- .../users/migrations/0002_user_is_online.py | 18 -- ...ns_user_custom_tournament_wins_and_more.py | 28 --- .../migrations/0004_alter_user_avatar.py | 18 -- .../migrations/0005_alter_user_avatar.py | 18 -- .../migrations/0006_alter_user_avatar.py | 18 -- .../migrations/0007_alter_user_avatar.py | 18 -- .../migrations/0008_remove_user_last_login.py | 17 -- db/Dockerfile | 3 + docker-compose.yml | 233 ++++++++++-------- frontend/src/global.js | 4 +- init.sh | 4 +- nginx/Dockerfile | 46 ++-- nginx/config/nginx.conf | 4 +- 19 files changed, 175 insertions(+), 483 deletions(-) delete mode 100644 backend/friends/migrations/0001_initial.py delete mode 100644 backend/games/migrations/0001_initial.py delete mode 100644 backend/games/migrations/0002_game_started_at.py delete mode 100644 backend/games/migrations/0003_casualgamelistview.py delete mode 100644 backend/users/migrations/0001_initial.py delete mode 100644 backend/users/migrations/0002_user_is_online.py delete mode 100644 backend/users/migrations/0003_user_custom_1vs1_wins_user_custom_tournament_wins_and_more.py delete mode 100644 backend/users/migrations/0004_alter_user_avatar.py delete mode 100644 backend/users/migrations/0005_alter_user_avatar.py delete mode 100644 backend/users/migrations/0006_alter_user_avatar.py delete mode 100644 backend/users/migrations/0007_alter_user_avatar.py delete mode 100644 backend/users/migrations/0008_remove_user_last_login.py create mode 100644 db/Dockerfile diff --git a/backend/friends/migrations/0001_initial.py b/backend/friends/migrations/0001_initial.py deleted file mode 100644 index 23d9a7c7e..000000000 --- a/backend/friends/migrations/0001_initial.py +++ /dev/null @@ -1,32 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-14 05:54 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='Friend', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('status', models.PositiveSmallIntegerField(choices=[(0, '대기'), (1, '수락'), (2, '거절')], default=0)), - ('created_at', models.DateTimeField(auto_now_add=True)), - ('updated_at', models.DateTimeField(auto_now=True)), - ('friend_id', models.ForeignKey(db_column='friend_id', on_delete=django.db.models.deletion.PROTECT, related_name='friend_who_is_requested', to=settings.AUTH_USER_MODEL)), - ('user_id', models.ForeignKey(db_column='user_id', on_delete=django.db.models.deletion.PROTECT, related_name='user_who_is_requesting', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'db_table': 'friends', - 'unique_together': {('user_id', 'friend_id')}, - }, - ), - ] diff --git a/backend/games/migrations/0001_initial.py b/backend/games/migrations/0001_initial.py deleted file mode 100644 index e21f73493..000000000 --- a/backend/games/migrations/0001_initial.py +++ /dev/null @@ -1,88 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-14 05:54 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='CasualGameView', - fields=[ - ('game_id', models.IntegerField(primary_key=True, serialize=False)), - ('mode', models.PositiveSmallIntegerField()), - ], - options={ - 'db_table': 'casual_game_view', - 'managed': False, - }, - ), - migrations.CreateModel( - name='GameRecordView', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('game_id', models.IntegerField()), - ('mode', models.IntegerField()), - ('user_id', models.IntegerField()), - ], - options={ - 'db_table': 'game_record_view', - 'managed': False, - }, - ), - migrations.CreateModel( - name='RankGameView', - fields=[ - ('game_id', models.IntegerField(primary_key=True, serialize=False)), - ], - options={ - 'db_table': 'rank_game_view', - 'managed': False, - }, - ), - migrations.CreateModel( - name='Result', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('player1_score', models.PositiveSmallIntegerField(blank=True, null=True)), - ('player2_score', models.PositiveSmallIntegerField(blank=True, null=True)), - ('started_at', models.DateTimeField(blank=True, null=True)), - ('playtime', models.TimeField(blank=True, null=True)), - ('player1', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_player1', to=settings.AUTH_USER_MODEL)), - ('player2', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_player2', to=settings.AUTH_USER_MODEL)), - ('winner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'db_table': 'results', - }, - ), - migrations.CreateModel( - name='Game', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('mode', models.PositiveSmallIntegerField(choices=[(0, '1vs1'), (1, 'casual_tournament'), (2, 'rank')])), - ('title', models.CharField(blank=True, null=True)), - ('password', models.CharField(blank=True, null=True)), - ('status', models.PositiveSmallIntegerField(choices=[(0, 'AVAILABLE_WAITING'), (1, 'FULL_WAITING'), (2, 'IN_GAME'), (3, 'FINISHED'), (4, 'DELETED')])), - ('created_at', models.DateTimeField(auto_now_add=True)), - ('manager', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), - ('match1', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_match1', to='games.result')), - ('match2', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_match2', to='games.result')), - ('match3', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='result_match3', to='games.result')), - ('player1', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='player1_id', to=settings.AUTH_USER_MODEL)), - ('player2', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='player2_id', to=settings.AUTH_USER_MODEL)), - ('player3', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='player3_id', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'db_table': 'games', - }, - ), - ] diff --git a/backend/games/migrations/0002_game_started_at.py b/backend/games/migrations/0002_game_started_at.py deleted file mode 100644 index cbdd97752..000000000 --- a/backend/games/migrations/0002_game_started_at.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-17 14:34 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('games', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='game', - name='started_at', - field=models.DateTimeField(blank=True, null=True), - ), - ] diff --git a/backend/games/migrations/0003_casualgamelistview.py b/backend/games/migrations/0003_casualgamelistview.py deleted file mode 100644 index 5f040d07e..000000000 --- a/backend/games/migrations/0003_casualgamelistview.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-20 06:46 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('games', '0002_game_started_at'), - ] - - operations = [ - migrations.CreateModel( - name='CasualGameListView', - fields=[ - ('game_id', models.IntegerField(primary_key=True, serialize=False)), - ('mode', models.PositiveSmallIntegerField()), - ('status', models.PositiveSmallIntegerField()), - ], - options={ - 'db_table': 'casual_game_list_view', - 'managed': False, - }, - ), - ] diff --git a/backend/src/settings.py b/backend/src/settings.py index 97aebf2d0..a517029e6 100644 --- a/backend/src/settings.py +++ b/backend/src/settings.py @@ -31,8 +31,8 @@ def wait_for_vault_client(client, retries=5, delay=5): if DEBUG: # DB DB_HOST = config('DB_HOST') - DB_PASSWORD = config('DB_PASSWORD') - DB_USER = config('DB_USER') + POSTGRES_PASSWORD = config('POSTGRES_PASSWORD') + POSTGRES_USER = config('POSTGRES_USER') DB_DATABASE = config('DB_DATABASE') DB_PORT = config('DB_PORT') @@ -175,11 +175,11 @@ def wait_for_vault_client(client, retries=5, delay=5): 'django_prometheus', ] -ELASTICSEARCH_DSL = { - 'default': { - 'hosts': 'localhost:9200' - }, -} +# ELASTICSEARCH_DSL = { +# 'default': { +# 'hosts': 'localhost:9200' +# }, +# } AUTH_USER_MODEL = 'users.User' @@ -230,9 +230,9 @@ def wait_for_vault_client(client, retries=5, delay=5): DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', - 'NAME': env('DB_DATABASE'), - 'USER': env('DB_USER'), - 'PASSWORD': env('DB_PASSWORD'), + 'NAME': 'db_name', + 'USER': env('POSTGRES_USER'), + 'PASSWORD': env('POSTGRES_PASSWORD'), 'HOST': env('DB_HOST'), 'PORT': env('DB_PORT'), } @@ -241,11 +241,11 @@ def wait_for_vault_client(client, retries=5, delay=5): DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', - 'NAME': db_name, - 'USER': db_user, - 'PASSWORD': db_password, - 'HOST': db_host, - 'PORT': db_port, + 'NAME': 'db_name', + 'USER': env('POSTGRES_USER'), + 'PASSWORD': env('POSTGRES_PASSWORD'), + 'HOST': env('DB_HOST'), + 'PORT': env('DB_PORT'), } } diff --git a/backend/users/migrations/0001_initial.py b/backend/users/migrations/0001_initial.py deleted file mode 100644 index 7a2d00e5e..000000000 --- a/backend/users/migrations/0001_initial.py +++ /dev/null @@ -1,36 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-08 04:53 - -from django.db import migrations, models -import django.utils.timezone - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('auth', '0012_alter_user_first_name_max_length'), - ] - - operations = [ - migrations.CreateModel( - name='User', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), - ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), - ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), - ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), - ('email', models.EmailField(max_length=254, unique=True, verbose_name='이메일 주소')), - ('nickname', models.CharField(blank=True, max_length=8, null=True, unique=True)), - ('rating', models.PositiveIntegerField(default=0)), - ('avatar', models.PositiveSmallIntegerField(choices=[(0, 'chewbacca.png'), (1, 'darth_vader.png'), (2, 'luke_skywalker.png'), (3, 'han_solo.png'), (4, 'yoda.png')], null=True)), - ('verification_code', models.CharField(blank=True, max_length=6, null=True)), - ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), - ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), - ], - options={ - 'db_table': 'users', - }, - ), - ] diff --git a/backend/users/migrations/0002_user_is_online.py b/backend/users/migrations/0002_user_is_online.py deleted file mode 100644 index 823742d53..000000000 --- a/backend/users/migrations/0002_user_is_online.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-15 08:29 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='user', - name='is_online', - field=models.BooleanField(default=False), - ), - ] diff --git a/backend/users/migrations/0003_user_custom_1vs1_wins_user_custom_tournament_wins_and_more.py b/backend/users/migrations/0003_user_custom_1vs1_wins_user_custom_tournament_wins_and_more.py deleted file mode 100644 index 5d7d1cd41..000000000 --- a/backend/users/migrations/0003_user_custom_1vs1_wins_user_custom_tournament_wins_and_more.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-15 12:28 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0002_user_is_online'), - ] - - operations = [ - migrations.AddField( - model_name='user', - name='custom_1vs1_wins', - field=models.IntegerField(default=0), - ), - migrations.AddField( - model_name='user', - name='custom_tournament_wins', - field=models.IntegerField(default=0), - ), - migrations.AddField( - model_name='user', - name='rank_wins', - field=models.IntegerField(default=0), - ), - ] diff --git a/backend/users/migrations/0004_alter_user_avatar.py b/backend/users/migrations/0004_alter_user_avatar.py deleted file mode 100644 index 6d45ee9d8..000000000 --- a/backend/users/migrations/0004_alter_user_avatar.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-17 18:49 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0003_user_custom_1vs1_wins_user_custom_tournament_wins_and_more'), - ] - - operations = [ - migrations.AlterField( - model_name='user', - name='avatar', - field=models.ImageField(null=True, upload_to=''), - ), - ] diff --git a/backend/users/migrations/0005_alter_user_avatar.py b/backend/users/migrations/0005_alter_user_avatar.py deleted file mode 100644 index ccc34bf29..000000000 --- a/backend/users/migrations/0005_alter_user_avatar.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-17 19:25 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0004_alter_user_avatar'), - ] - - operations = [ - migrations.AlterField( - model_name='user', - name='avatar', - field=models.ImageField(null=True, upload_to='../../frontend/src/assets/avatars'), - ), - ] diff --git a/backend/users/migrations/0006_alter_user_avatar.py b/backend/users/migrations/0006_alter_user_avatar.py deleted file mode 100644 index 28a82e3db..000000000 --- a/backend/users/migrations/0006_alter_user_avatar.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-17 19:39 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0005_alter_user_avatar'), - ] - - operations = [ - migrations.AlterField( - model_name='user', - name='avatar', - field=models.ImageField(null=True, upload_to='ft_transcendence/frontend/src/assets/avatars'), - ), - ] diff --git a/backend/users/migrations/0007_alter_user_avatar.py b/backend/users/migrations/0007_alter_user_avatar.py deleted file mode 100644 index 836499bb1..000000000 --- a/backend/users/migrations/0007_alter_user_avatar.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-17 19:53 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0006_alter_user_avatar'), - ] - - operations = [ - migrations.AlterField( - model_name='user', - name='avatar', - field=models.ImageField(null=True, upload_to='avatar/'), - ), - ] diff --git a/backend/users/migrations/0008_remove_user_last_login.py b/backend/users/migrations/0008_remove_user_last_login.py deleted file mode 100644 index 38de6503e..000000000 --- a/backend/users/migrations/0008_remove_user_last_login.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 4.2.8 on 2024-02-20 06:46 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0007_alter_user_avatar'), - ] - - operations = [ - migrations.RemoveField( - model_name='user', - name='last_login', - ), - ] diff --git a/db/Dockerfile b/db/Dockerfile new file mode 100644 index 000000000..edcee13df --- /dev/null +++ b/db/Dockerfile @@ -0,0 +1,3 @@ +FROM postgres:16.2-alpine3.18 + +# 필요한 패키지 설치 diff --git a/docker-compose.yml b/docker-compose.yml index c53517a62..dfa15e39e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.0' +version: '3.8' services: hashicorp_vault: @@ -14,7 +14,6 @@ services: - "${VAULT_LOG_PATH}:/vault/logs" - "${VAULT_TOKEN_PATH}:/vault/config" - "${CERTS_PATH}:/vault/certs" - environment: VAULT_ADDR: "https://hashicorp_vault:8200" cap_add: @@ -23,7 +22,8 @@ services: - app_network django_node_app: - build: . + build: + dockerfile: Dockerfile container_name: django_node_container ports: - 8443:8443 @@ -34,13 +34,34 @@ services: - static-volume:/backend/static - "${CERTS_PATH}:/backend/certs" - "${DJANGO_LOGS}:/var/log/djangolog" + env_file: + - .env environment: VAULT_URL: "https://hashicorp_vault:8200" VAULT_TOKEN: ${VAULT_TOKEN} BASE_URL: ${BASE_URL} - depends_on: - - hashicorp_vault + postgresql: + condition: service_healthy + + postgresql: + build: + context: ./db + dockerfile: Dockerfile + container_name: db_container + ports: + - 5432:5432 + volumes: + - "${POSTGRES_DATA}:/var/lib/postgresql/data" + env_file: + - .env + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"] + interval: 10s + timeout: 5s + retries: 5 + networks: + - app_network nginx: build: ./nginx @@ -61,113 +82,113 @@ services: networks: - app_network - elasticsearch: - build: - context: ./elk/elasticsearch - dockerfile: Dockerfile - volumes: - - "${ELASTIC_DATA}:/usr/share/elasticsearch/data" - - "${ELASTIC_CERTS}:/usr/share/elasticsearch/config/certs" - environment: - discovery.type : single-node - ELASTIC_PW : ${ELASTIC_PW} - ES_JAVA_OPTS: "-Xms2g -Xmx2g" - ES_CERTS_PW: ${ES_CERTS_PW} - ports: - - 9200:9200 - - 9300:9300 - networks: - - app_network +# elasticsearch: +# build: +# context: ./elk/elasticsearch +# dockerfile: Dockerfile +# volumes: +# - "${ELASTIC_DATA}:/usr/share/elasticsearch/data" +# - "${ELASTIC_CERTS}:/usr/share/elasticsearch/config/certs" +# environment: +# discovery.type : single-node +# ELASTIC_PW : ${ELASTIC_PW} +# ES_JAVA_OPTS: "-Xms2g -Xmx2g" +# ES_CERTS_PW: ${ES_CERTS_PW} +# ports: +# - 9200:9200 +# - 9300:9300 +# networks: +# - app_network - # elasticsearch-setup-passwords interactive --url "https://localhost:9200" -E xpack.security.http.ssl.verification_mode=none +# # elasticsearch-setup-passwords interactive --url "https://localhost:9200" -E xpack.security.http.ssl.verification_mode=none - logstash: - build: ./elk/logstash - container_name: logstash_container - environment: - LS_JAVA_OPTS: "-Xms2g -Xmx2g" - ELASTIC_PW: ${ELASTIC_PW} - ES_CERTS_PW: ${ES_CERTS_PW} - volumes: - - "${ELASTIC_CERTS}:/usr/share/logstash/config/certs" - - "${NGINX_LOGS}:/usr/share/logstash/log/nginx_logs" - - "${DJANGO_LOGS}:/usr/share/logstash/log/django_logs" - ports: - - 5333:5333 - depends_on: - - elasticsearch - networks: - - app_network +# logstash: +# build: ./elk/logstash +# container_name: logstash_container +# environment: +# LS_JAVA_OPTS: "-Xms2g -Xmx2g" +# ELASTIC_PW: ${ELASTIC_PW} +# ES_CERTS_PW: ${ES_CERTS_PW} +# volumes: +# - "${ELASTIC_CERTS}:/usr/share/logstash/config/certs" +# - "${NGINX_LOGS}:/usr/share/logstash/log/nginx_logs" +# - "${DJANGO_LOGS}:/usr/share/logstash/log/django_logs" +# ports: +# - 5333:5333 +# depends_on: +# - elasticsearch +# networks: +# - app_network - kibana: - build: ./elk/kibana - container_name: kibana_container - volumes: - - "${KIBANA_DATA}:/usr/share/kibana/data" - - "${ELASTIC_CERTS}:/usr/share/kibana/config/certs" - environment: - ELASTICSEARCH_URL: https://elasticsearch:9200 - ELASTIC_PW: ${ELASTIC_PW} - ES_CERTS_PW: ${ES_CERTS_PW} - ports: - - 5601:5601 - depends_on: - - elasticsearch - networks: - - app_network +# kibana: +# build: ./elk/kibana +# container_name: kibana_container +# volumes: +# - "${KIBANA_DATA}:/usr/share/kibana/data" +# - "${ELASTIC_CERTS}:/usr/share/kibana/config/certs" +# environment: +# ELASTICSEARCH_URL: https://elasticsearch:9200 +# ELASTIC_PW: ${ELASTIC_PW} +# ES_CERTS_PW: ${ES_CERTS_PW} +# ports: +# - 5601:5601 +# depends_on: +# - elasticsearch +# networks: +# - app_network - node_exporter: - image: prom/node-exporter - container_name: node_exporter_container - ports: - - 9100:9100 - volumes: - - "/proc:/host/proc" - - "/sys:/host/sys" - - "/:/rootfs" - - "/etc:/host/etc:ro" - - "${CERTS_PATH}:/etc/ssl/certs" - - "${PROMETHEUS_CONFIG}:/etc/node_exporter" - command: - - '--path.procfs=/host/proc' - - '--path.sysfs=/host/sys' - - '--path.rootfs=/rootfs' - - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)' - - '--web.config.file=/etc/node_exporter/web.yml' - networks: - - app_network +# node_exporter: +# image: prom/node-exporter +# container_name: node_exporter_container +# ports: +# - 9100:9100 +# volumes: +# - "/proc:/host/proc" +# - "/sys:/host/sys" +# - "/:/rootfs" +# - "/etc:/host/etc:ro" +# - "${CERTS_PATH}:/etc/ssl/certs" +# - "${PROMETHEUS_CONFIG}:/etc/node_exporter" +# command: +# - '--path.procfs=/host/proc' +# - '--path.sysfs=/host/sys' +# - '--path.rootfs=/rootfs' +# - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)' +# - '--web.config.file=/etc/node_exporter/web.yml' +# networks: +# - app_network - prometheus: - build: - context: ./prometheus - dockerfile: Dockerfile - container_name: prometheus_container - env_file: - - .env - volumes: - - "${PROMETHEUS_DATA}:/prometheus/data" - - "${PROMETHEUS_CONFIG}:/prometheus/config" - - "${CERTS_PATH}:/etc/ssl/certs" - ports: - - 9090:9090 - networks: - - app_network +# prometheus: +# build: +# context: ./prometheus +# dockerfile: Dockerfile +# container_name: prometheus_container +# env_file: +# - .env +# volumes: +# - "${PROMETHEUS_DATA}:/prometheus/data" +# - "${PROMETHEUS_CONFIG}:/prometheus/config" +# - "${CERTS_PATH}:/etc/ssl/certs" +# ports: +# - 9090:9090 +# networks: +# - app_network - grafana: - build: - context: ./grafana - dockerfile: Dockerfile - container_name: grafana_container - env_file: - - .env - volumes: - - "${GRAFANA_DATA}:/var/lib/grafana" - - "${GRAFANA_CONFIG}:/etc/grafana/grafana.ini" - - "${CERTS_PATH}:/etc/ssl/certs" - ports: - - 3000:3000 - networks: - - app_network +# grafana: +# build: +# context: ./grafana +# dockerfile: Dockerfile +# container_name: grafana_container +# env_file: +# - .env +# volumes: +# - "${GRAFANA_DATA}:/var/lib/grafana" +# - "${GRAFANA_CONFIG}:/etc/grafana/grafana.ini" +# - "${CERTS_PATH}:/etc/ssl/certs" +# ports: +# - 3000:3000 +# networks: +# - app_network volumes: static-volume: diff --git a/frontend/src/global.js b/frontend/src/global.js index 089c579ae..28bb4377f 100644 --- a/frontend/src/global.js +++ b/frontend/src/global.js @@ -1,7 +1,7 @@ const devBackend = "http://localhost:8000/api"; const devWebSocket = "ws://localhost:8000/ws"; -const prodBackend = "https://10.14.10.2:443/api"; -const prodWebSocket = "wss://10.14.10.2:443/ws"; +const prodBackend = "https://10.14.5.2:443/api"; +const prodWebSocket = "wss://10.14.5.2:443/ws"; const getAPIUrl = () => { return window.mode === "dev" ? devBackend : prodBackend; diff --git a/init.sh b/init.sh index 69e1ac78a..7f0c872dc 100644 --- a/init.sh +++ b/init.sh @@ -1,7 +1,9 @@ #!/bin/sh - export DJANGO_SETTINGS_MODULE=src.settings +python manage.py makemigrations +python manage.py migrate + python manage.py collectstatic --noinput daphne -p 6 -b 0.0.0.0 -e ssl:8443:privateKey=/backend/certs/server.key:certKey=/backend/certs/server.crt src.asgi:application \ No newline at end of file diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 7193fdba2..0d56db51a 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -4,31 +4,31 @@ FROM nginx:1.21.6-alpine RUN apk add --no-cache git build-base libtool automake autoconf zlib-dev pcre-dev openssl-dev linux-headers openssl # ModSecurity 다운로드 및 컴파일 -RUN git clone --depth 1 https://github.com/SpiderLabs/ModSecurity.git /usr/local/src/modsecurity \ - && cd /usr/local/src/modsecurity \ - && git submodule init \ - && git submodule update \ - && ./build.sh \ - && ./configure \ - && make \ - && make install +# RUN git clone --depth 1 https://github.com/SpiderLabs/ModSecurity.git /usr/local/src/modsecurity \ + # && cd /usr/local/src/modsecurity \ + # && git submodule init \ + # && git submodule update \ + # && ./build.sh \ + # && ./configure \ + # && make \ + # && make install # ModSecurity-nginx 커넥터 다운로드 -RUN git clone --depth 1 https://github.com/SpiderLabs/ModSecurity-nginx.git /usr/local/src/modsecurity-nginx +# RUN git clone --depth 1 https://github.com/SpiderLabs/ModSecurity-nginx.git /usr/local/src/modsecurity-nginx # Nginx 컴파일을 위한 준비 및 ModSecurity 모듈 빌드 -ARG NGINX_VERSION=1.21.6 -RUN wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ - && tar zxvf nginx-${NGINX_VERSION}.tar.gz \ - && cd nginx-${NGINX_VERSION} \ - && ./configure --with-compat --add-dynamic-module=/usr/local/src/modsecurity-nginx \ - && make modules \ - && cp objs/ngx_http_modsecurity_module.so /usr/lib/nginx/modules +# ARG NGINX_VERSION=1.21.6 +# RUN wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ + # && tar zxvf nginx-${NGINX_VERSION}.tar.gz \ + # && cd nginx-${NGINX_VERSION} \ + # && ./configure --with-compat --add-dynamic-module=/usr/local/src/modsecurity-nginx \ + # && make modules \ + # && cp objs/ngx_http_modsecurity_module.so /usr/lib/nginx/modules # ModSecurity 설정 디렉토리 생성 및 파일 복사 -RUN mkdir -p /etc/nginx/modsecurity -COPY ./config/modsecurity.conf /etc/nginx/modsecurity/ -COPY ./config/owasp-crs /etc/nginx/modsecurity/owasp-crs +# RUN mkdir -p /etc/nginx/modsecurity +# COPY ./config/modsecurity.conf /etc/nginx/modsecurity/ +# COPY ./config/owasp-crs /etc/nginx/modsecurity/owasp-crs RUN apk add --no-cache nss-tools RUN wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-linux-amd64 -O /usr/local/bin/mkcert @@ -41,9 +41,9 @@ RUN mkcert -key-file /etc/nginx/certs/server.key -cert-file /etc/nginx/certs/ser # Nginx 설정 파일 복사 및 모듈 로드 COPY ./config/nginx.conf /etc/nginx/nginx.conf -RUN mkdir -p /etc/nginx/modules-load.d/ \ - && echo 'load_module /usr/lib/nginx/modules/ngx_http_modsecurity_module.so;' > /etc/nginx/modules-load.d/00-modsecurity.conf \ - && cat /etc/nginx/nginx.conf > /etc/nginx/nginx.conf.bak \ - && cat /etc/nginx/modules-load.d/00-modsecurity.conf /etc/nginx/nginx.conf.bak > /etc/nginx/nginx.conf +# RUN mkdir -p /etc/nginx/modules-load.d/ \ + # && echo 'load_module /usr/lib/nginx/modules/ngx_http_modsecurity_module.so;' > /etc/nginx/modules-load.d/00-modsecurity.conf \ + # && cat /etc/nginx/nginx.conf > /etc/nginx/nginx.conf.bak \ + # && cat /etc/nginx/modules-load.d/00-modsecurity.conf /etc/nginx/nginx.conf.bak > /etc/nginx/nginx.conf CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx/config/nginx.conf b/nginx/config/nginx.conf index 99834edb1..d09a9ac3a 100644 --- a/nginx/config/nginx.conf +++ b/nginx/config/nginx.conf @@ -37,8 +37,8 @@ http { keepalive_timeout 65; - modsecurity_rules_file /etc/nginx/modsecurity/modsecurity.conf; - modsecurity on; + # modsecurity_rules_file /etc/nginx/modsecurity/modsecurity.conf; + # modsecurity on; # Django 애플리케이션에 대한 설정