Commit 41d4d0b9 authored by insun park's avatar insun park
Browse files

docker/README.md 및 docker 하위 프로젝트 일괄 추가

parent c384e1fe
# Byte-compiled / optimized / DLL files
__pycache__/
*.pyc
*.pyo
*.pyd
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Environments
.env
.env.*
!.env.example
env/
venv/
ENV/
venv.bak/
env.bak/
# Docker
docker-compose.override.yml
**/data/
**/db_data/
**/uploads/
# Databases
*.sqlite3
*.db
# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
# Node
node_modules/
.npm
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# IDE settings
.idea/
.vscode/
*.swp
*~
\ No newline at end of file
# Docker 프로젝트 모음
이 디렉토리는 다양한 목적의 Docker 기반 애플리케이션 및 서비스 환경을 포함하고 있습니다. 각 하위 디렉토리는 독립적인 프로젝트이며, 자체 `README.md` 파일에 더 자세한 설명이 있습니다.
## 🚀 프로젝트 목록
| 프로젝트 디렉토리 | 설명 | 주요 기술 | 실행 방법 |
| --- | --- | --- | --- |
| **`docker_all`** | Java 웹 개발 및 협업에 필요한 모든 서비스(Tomcat, MariaDB, SVN)를 통합한 올인원 개발 서버입니다. | `Tomcat`, `MariaDB`, `SVN`, `Java 8` | `./rebuild_docker.sh` |
| **`docker_centos`** | CentOS 6 기반의 레거시 APM(Apache, PHP, MySQL) 스택을 구축하고, 대용량 SQL 덤프를 자동으로 복원합니다. | `CentOS 6`, `Apache`, `MySQL`, `PHP` | `./rebuild_docker.sh` 또는 수동 |
| **`docker_centos_desktop`** | CentOS 6.10 기반의 웹 서버 환경으로, 소스 컴파일을 통해 최신 빌드 도구(GCC 8)를 설치합니다. | `CentOS 6.10`, `Apache`, `MySQL`, `PHP` | `./rebuild_docker.sh` |
| **`docker_crowling`** | 외부 `geumdo_analysis` 디렉토리의 Python 크롤링/분석 애플리케이션을 FastAPI 서버로 실행합니다. | `FastAPI`, `Python` | `./rebuild.sh` 및 수동 설정 |
| **`docker_db`** | MariaDB 서버 환경을 구축하며, 컨테이너 시작 시 원격 접속 가능한 `root` 계정을 자동으로 설정합니다. | `MariaDB`, `Ubuntu 20.04` | `./rebuild.sh` |
| **`docker_db_new`** | MariaDB 서버 환경으로, `make_root_remote_host.sh` 스크립트를 통해 수동으로 원격 접속을 설정해야 합니다. | `MariaDB`, `Ubuntu 20.04` | `./rebuild.sh` 및 수동 설정 |
| **`docker_fastapi`** | 스마트스토어, 쿠팡 상품 정보 및 리뷰를 수집하고 AI 감성 분석을 수행하는 크롤링 시스템입니다. | `FastAPI`, `Selenium`, `TensorFlow` | `docker-compose up -d` |
| **`docker_fastapi_new`** | AI 감성 분석 및 크롤링 시스템으로, Selenium, Mecab, TensorFlow 등을 포함합니다. | `FastAPI`, `Selenium`, `Mecab`, `Java 8` | `./rebuild.sh` |
| **`docker_flask_proxy`** | 특정 URL로 요청을 전달하는 간단한 HTTPS 리버스 프록시 서버입니다. | `Flask`, `Python` | `./rebuild_docker.sh` |
| **`docker_gitlab`** | 공식 이미지를 사용하여 GitLab CE(Community Edition) 서버를 배포합니다. | `GitLab CE` | `docker-compose up -d` |
| **`docker_java`** | Java 웹 개발을 위한 완전한 환경(Tomcat, MariaDB, SSH)을 제공합니다. | `Tomcat`, `MariaDB`, `Java 8` | `./rebuild_docker.sh` |
| **`docker_jenkins`** | Jenkins CI/CD 자동화 서버를 구축하며, 데이터는 호스트에 영속적으로 저장됩니다. | `Jenkins`, `OpenJDK 8`, `MariaDB` | `./rebuild.sh` |
| **`docker_jupyter`** | GPU를 지원하는 Jupyter Lab 실행 환경으로, PyTorch가 사전 설치되어 있습니다. | `Jupyter Lab`, `PyTorch`, `GPU` | `docker-compose up -d` |
| **`docker_jupyter_gpu_docker`** | TensorFlow와 PyTorch를 모두 지원하는 범용 GPU 딥러닝 연구 환경입니다. | `Jupyter Lab`, `TensorFlow`, `PyTorch`, `CUDA` | `./rebuild_with_fix.sh` |
| **`docker_mailserver`** | Poste.io를 사용하여 SMTP, IMAP, 웹메일 등 모든 기능을 갖춘 올인원 메일 서버를 구축합니다. | `Poste.io` | `./rebuild.sh` |
| **`docker_metaverse`** | PHP와 Node.js 기반의 복합 웹 애플리케이션('노담') 서버 환경을 패키징합니다. | `PHP`, `Node.js`, `MySQL`, `Nginx` | `./rebuild_docker.sh` |
| **`docker_nginx_proxy`** | Nginx 기반 리버스 프록시 서버로, Let's Encrypt `certbot`을 통해 SSL/TLS 인증서를 관리합니다. | `Nginx`, `Certbot`, `OpenSSL` | `./rebuild_docker.sh` |
| **`docker_open_webui`** | Ollama, OpenAI 등 다양한 LLM Runner를 지원하는 사용자 친화적인 웹 UI입니다. | `Docker`, `Ollama`, `Python` | `docker run ...` |
| **`docker_posivibes`** | 'Posivibes'라는 Java 웹 애플리케이션을 실행하기 위한 Tomcat 8.5 기반의 WAS 환경입니다. | `Tomcat 8.5`, `Java 8` | `./rebuild_docker.sh` |
| **`docker_prusa_exporter`** | Prusa 3D 프린터의 상태 정보를 Prometheus로 익스포트하여 Grafana로 모니터링합니다. | `Prometheus`, `Grafana`, `Go` | `docker compose up` |
| **`docker_registry`** | Docker 이미지를 저장하고 관리할 수 있는 사설 레지스트리(Web UI 포함)를 구축합니다. | `Docker Registry`, `Web UI` | `docker-compose up -d` |
| **`docker_securedb`** | 'DBSEC' 데이터베이스 보안 솔루션을 실행하기 위한 환경을 제공합니다. | `OpenJDK 11`, `Ubuntu 20.04` | `./rebuild_docker.sh` |
| **`docker_ubuntu_ssh`** | `sudo` 권한을 가진 일반 사용자가 설정된 기본 Ubuntu 22.04 + SSH 서버 환경입니다. | `Ubuntu 22.04`, `SSH` | `./rebuild_docker.sh` |
| **`docker_vnexa_api`** | 호출 시 마크다운 텍스트를 무작위로 반환하는 간단한 Flask API 서버 예제입니다. | `Flask`, `Python`, `Ubuntu 20.04` | `./rebuild_docker.sh` |
| **`docker_was`** | `sabg.war`라는 특정 Java 웹 애플리케이션을 배포하기 위한 Tomcat 8.5 기반의 WAS 환경입니다. | `Tomcat 8.5`, `Java 8` | `./rebuild_docker.sh` |
| **`docker_was_upgrade`** | OpenJDK 11과 Tomcat 9를 기반으로 하는 업그레이드된 Java WAS 환경입니다. (복제본) | `Tomcat 9`, `Java 11` | `./rebuild_docker.sh` |
| **`docker_was_upgrade_http`** | OpenJDK 11과 Tomcat 9를 기반으로 하는 업그레이드된 Java WAS 환경입니다. | `Tomcat 9`, `Java 11` | `./rebuild_docker.sh` |
| **`docker-windows-vm`** | Docker 컨테이너 내부에 KVM을 설치하고, Vagrant를 사용해 Windows 10 VM을 구동하는 복합 가상화 환경입니다. | `KVM`, `Vagrant`, `Windows 10`, `RDP` | `docker-compose up -d` |
| **`examples`** | Spring Boot 등 내장 WAS를 사용하는 Java Maven 프로젝트를 Docker화하는 예제/템플릿입니다. | `Java`, `Maven`, `Spring Boot` | `./rebuild_docker.sh` |
| **`geumdo-rag-chat-bot`** | 사내 GitLab 코드에 대해 자연어 질의를 할 수 있는 RAG 기반 챗봇 시스템입니다. | `RAG`, `LangChain`, `FastAPI`, `Streamlit` | `docker-compose up --build -d` |
| **`gpu_cooling_monitor`** | TIG 스택(InfluxDB, Grafana)을 활용하여 서버의 GPU 및 시스템 냉각 상태를 실시간으로 모니터링합니다. | `InfluxDB`, `Grafana`, `Python`, `Slack` | `docker-compose up -d` |
| **`jupyter_geumdo_lab`** | Kubernetes(K8s) 기반의 다중 사용자 JupyterHub 서비스로, Google OAuth 인증과 동적 GPU/CPU 서버 생성을 지원합니다. | `Kubernetes`, `JupyterHub`, `NFS`, `OAuth` | `helm upgrade ...` |
| **`docker_3dp`** | Nextcloud 파일 관리, 웹 기반 원격 슬라이싱(PrusaSlicer), 프린터 제어 기능을 통합한 3D 프린팅 솔루션입니다. | `Nextcloud`, `PrusaSlicer`, `Flask`, `PHP` | `./rebuild_docker.sh` |
---
보다 자세한 내용은 각 디렉토리의 `README.md` 파일을 참고하십시오.
\ No newline at end of file
# os with ssh
# images
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
# package procedure(update&upgrade&install)
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y vim net-tools zip unzip apt-utils iputils-ping wget tar curl language-pack-ko openssh-server openjdk-17-jdk maven mariadb-server python3 python3-venv python3-pip && \
apt-get install -y libfuse2 libglu1-mesa ibwebkit2gtk-4.0-dev
#아래 쪽은 prusaSlicer를 위한 library임
# Set up configuration for SSH
RUN mkdir /var/run/sshd
RUN echo 'root:!@#gds$%^' | chpasswd
RUN sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config
# SSH login fix. Otherwise, user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
# env
RUN echo "export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" >> /etc/profile && \
echo "export PATH=$PATH:$JAVA_HOME/bin" >> /etc/profile && \
echo "export LANG=ko_KR.UTF-8" >> /etc/profile && \
echo "export VENV_HOME=/home/gds/printer/venv/" >> /etc/profile && \
echo "export PATH=$PATH:$VENV_HOME/bin" >> /etc/profile
#run script folder and copy script
RUN mkdir /service_script
COPY start_service.sh /service_script
COPY setting.sql /service_script
RUN chmod +x /service_script/start_service.sh
COPY PrusaSlicer /usr/bin
RUN chmod a+x /usr/bin/PrusaSlicer
# install nextcloud
RUN apt install -y nginx
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:ondrej/php -y
RUN apt update -y
RUN apt-get install -y \
php7.4 \
php7.4-fpm \
php7.4-mysql \
php7.4-gd \
php7.4-curl \
php7.4-xml \
php7.4-zip \
php7.4-mbstring \
php7.4-bcmath \
php7.4-gmp \
php7.4-imagick \
php7.4-intl
RUN ln -fs /usr/share/zoneinfo/Asia/Seoul /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata
WORKDIR /mnt
RUN mkdir nextcloud
RUN wget https://github.com/nextcloud/server/archive/refs/tags/v23.0.12.zip && \
unzip v23.0.12.zip -d /mnt/nextcloud && \
rm -rf v23.0.12.zip && \
chown -R www-data:www-data nextcloud && \
chmod -R 755 nextcloud
#package clean unused
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Expose port(SSH,NGINX,DB,FLASK,EMBED WAS)
EXPOSE 22 80 3000 3306 8080 8090 8060 8071
# Run SSH,NGINX,DB,FLASK,EMBED WAS
CMD ["/service_script/start_service.sh"]
# 3D 프린팅 관리 및 웹 슬라이싱 솔루션
본 프로젝트는 Docker 기반으로 패키징된 복합 3D 프린팅 관리 솔루션입니다. Nextcloud를 이용한 파일 관리, 웹 기반 원격 슬라이싱, 프린터 제어 기능을 통합하여 제공합니다.
## 기술 아키텍처
시스템은 모든 서비스가 단일 Docker 컨테이너에서 동작하는 올인원(All-in-one) 방식으로 설계되었습니다.
- **`Dockerfile`**: `ubuntu:20.04` 베이스 이미지 위에 다음과 같은 다양한 소프트웨어를 설치하여 복잡한 실행 환경을 구성합니다.
- **서버 소프트웨어**: Nginx, PHP 7.4-FPM, MariaDB, OpenSSH Server, OpenJDK 17
- **핵심 애플리케이션**:
- **Nextcloud 23.0.12**: 소스 코드를 직접 다운로드하여 설치. 파일 저장 및 관리의 중심 역할을 합니다.
- **PrusaSlicer**: AppImage 형태의 3D 프린터 슬라이서를 `/usr/bin`에 설치하여 커맨드라인으로 실행할 수 있도록 합니다.
- **Python 3 / Flask**: 슬라이싱 API 및 프린터 제어 프록시를 위한 웹 애플리케이션을 실행합니다.
- **`docker-compose.yml`**:
- **단일 서비스 `os`**: 모든 기능이 포함된 `Dockerfile`을 빌드하여 `docker_3dp`라는 이름의 컨테이너를 생성합니다.
- **포트 매핑**: Nextcloud(80), SSH(2212), Flask API(3000), MariaDB(3306), 다수의 임베디드 Tomcat(8080, 8090 등) 포트를 외부에 노출시켜 각 서비스에 접근할 수 있도록 합니다.
- **볼륨 및 권한**:
- 호스트의 `./printer` 폴더를 컨테이너의 Flask 앱 경로에, `./sites-available`을 Nginx 설정 경로에 마운트하여 외부에서 코드를 수정하고 관리할 수 있게 합니다.
- AppImage 실행에 필요한 FUSE(Filesystem in Userspace)를 사용하기 위해 `/dev/fuse` 장치를 마운트하고 `SYS_ADMIN` 권한과 `apparmor:unconfined` 설정을 부여합니다. 이는 컨테이너에 높은 수준의 권한을 부여하는 중요한 설정입니다.
### 워크플로우
1. **서비스 시작 (`start_service.sh`)**: 컨테이너가 시작되면 이 스크립트가 실행되어 SSH, MariaDB, PHP-FPM, Nginx 등 내부의 모든 데몬을 순차적으로 구동합니다. 또한, Flask 웹 애플리케이션을 실행하여 API 서비스 준비를 마칩니다.
2. **파일 관리 (Nextcloud)**: 사용자는 웹 브라우저를 통해 `http://<host-ip>`로 접속하여 Nextcloud에 3D 모델 파일(.stl)을 업로드하고 관리합니다.
3. **웹 슬라이싱 (Flask API)**:
- 외부 클라이언트는 `http://<host-ip>:3000/slice` 엔드포인트로 HTTP POST 요청을 보냅니다.
- 요청에는 슬라이싱할 STL 파일의 경로(Nextcloud 내)와 세부적인 프린팅 옵션(레이어 높이, 채우기 밀도 등)이 포함됩니다.
- Flask 앱은 `subprocess` 모듈을 사용하여 `PrusaSlicer` 커맨드라인을 실행하고, 전달받은 옵션을 적용하여 STL 파일을 G-code로 변환합니다.
- 슬라이싱 과정에서 발생하는 특정 오류를 감지하고, 이를 사용자 친화적인 한글 메시지와 코드로 변환하여 응답하는 상세한 예외 처리 기능이 포함되어 있습니다.
4. **프린터 제어 (PrusaLink Proxy)**:
- `http://<host-ip>:3000/proxy` 엔드포인트는 PrusaLink API를 중계하는 프록시 역할을 수행합니다. 이를 통해 실제 3D 프린터의 상태 조회, 출력 시작/중지 등의 원격 제어가 가능합니다.
## 기술 스택
- **오케스트레이션**: Docker, Docker Compose
- **웹 서버**: Nginx
- **애플리케이션 서버**: PHP 7.4-FPM, Flask (Python)
- **데이터베이스**: MariaDB
- **파일 공유 플랫폼**: Nextcloud 23.0.12
- **3D 슬라이서**: PrusaSlicer (AppImage)
- **주요 언어**: Python, Bash, PHP
## 실행 방법
### 사전 요구사항
- Docker 및 Docker Compose
- `3dp_dbconfig`, `3dp_dbdata` 라는 이름의 Docker 외부 볼륨이 사전에 생성되어 있어야 합니다.
```bash
docker volume create 3dp_dbconfig
docker volume create 3dp_dbdata
```
### 실행
1. **Docker 이미지 빌드 및 컨테이너 실행**:
```bash
# (선택) 재빌드 및 실행 스크립트
./rebuild_docker.sh
# 또는 docker-compose 직접 실행
docker-compose up --build -d
```
2. **애플리케이션 접근**:
- **Nextcloud**: `http://<서버_IP>`
- **슬라이싱 API**: `http://<서버_IP>:3000`
- **SSH**: `ssh root@<서버_IP> -p 2212` (초기 비밀번호는 Dockerfile 확인 필요)
### 중지
```bash
docker-compose down
```
\ No newline at end of file
version: '3'
services:
os:
build:
context: .
dockerfile: Dockerfile
container_name: docker_3dp
ports:
- "80:80" #NGINX NEXTCLOUD
- "2212:22" # SSH
- "3000:3000" #FLASK API
- "3306:3306" # DB
- "8080:8080" # EMBED TOMCAT
- "8090:8090" # EMBED TOMCAT(g3d)
- "8060:8060" # EMBED TOMCAT(rvoch3d)
- "8071:8071" # EMBED TOMCAT(g3d-test)
network_mode: bridge
restart: always
volumes:
- ./printer:/home/gds/printer
- ./data:/data
- ./sites-available:/etc/nginx/sites-available
- 3dp_dbconfig:/etc/mysql
- 3dp_dbdata:/var/lib/mysql
- /dev/fuse:/dev/fuse #App image 사용을 위한 device mount
devices:
- /dev/fuse #FUSE 디바이스 사용
cap_add:
- SYS_ADMIN #시스템 관리자 권한 추가
security_opt:
- apparmor:unconfined #AppArmor 비활성화
volumes:
3dp_dbconfig:
external: true
3dp_dbdata:
external: true
printer @ 1593600b
Subproject commit 1593600b24f7e7ab52862c2110ceace54aedb875
#!/bin/sh
# Build Docker image with explicit build context and Dockerfile path
# Check and create volumes if they don't exist
create_volume() {
docker volume inspect $1 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Volume '$1' already exists."
else
docker volume create --name=$1
echo "Volume '$1' created."
fi
}
create_volume 3dp_dbdata
create_volume 3dp_dbconfig
docker build -t .
# Run Docker Compose with a specific container name
docker-compose up -d --build
#원하는 루트 원격 계정 password 입력
grant all privileges on *.* to root@'%' identified by '!@#gds$%^';
flush privileges;
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
#listen 80 default_server;
#listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
#root /var/www/html;
# Add index.php to the list if you are using PHP
#index index.html index.htm index.nginx-debian.html;
#server_name _;
#location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
#}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
server {
listen 80;
server_name 3dp-nextcloud.geumdo.net;
index index.php;
root /mnt/nextcloud;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location = /.well-known/carddav {
return 301 $scheme://$host:$server_port/remote.php/dav;
}
location = /.well-known/caldav {
return 301 $scheme://$host:$server_port/remote.php/dav;
}
client_max_body_size 512M;
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
location / {
rewrite ^ /index.php;
}
location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
deny all;
}
location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
#fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
try_files $uri/ =404;
index index.php;
}
location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=15778463";
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Download-Options "noopen" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "none" always;
add_header X-XSS-Protection "1; mode=block" always;
access_log off;
}
location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
try_files $uri /index.php$request_uri;
access_log off;
}
}
#!/bin/bash
# 환경변수 적용
source /etc/profile && sleep 5
# SSH 서버 시작
/usr/sbin/sshd -D & sleep 5
# php-fpm (Nginx 전에 시작)
service php7.4-fpm start && sleep 5
# nginx
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/nextcloud.conf /etc/nginx/sites-enabled
service nginx start && sleep 5
# mariadb
service mysql start && sleep 5
# 3dp project
/data/webapps/swmb3d/start_service.sh start && sleep 5
# flask api
/home/gds/printer/venv/bin/python /home/gds/printer/app.py && sleep 5
# slicer install
cd /home/gds/printer
# Service 재시작 시 Docker가 종료되지 않도록 대기
tail -f /dev/null
# os with ssh
FROM ubuntu:20.04
# package procedure(update&upgrade&install)
RUN apt-get update && \
apt-get upgrade -y
RUN apt-get install -y openssh-server
RUN apt-get install -y mariadb-server mariadb-client
RUN apt-get install -y vim net-tools apt-utils iputils-ping wget tar curl language-pack-ko openjdk-8-jdk maven subversion apache2 libapache2-mod-svn
#package clean unused
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Set up configuration for SSH
RUN mkdir /var/run/sshd
RUN echo 'root:!@#gds$%^' | chpasswd
RUN sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config
# SSH login fix. Otherwise, user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
# SVN repository creation
RUN mkdir -p /svn/repos
RUN svnadmin create /svn/repos/geumdo_repo
# Apache SVN configuration
RUN echo "<Location /svn>" >> /etc/apache2/sites-available/svn.conf && \
echo " DAV svn" >> /etc/apache2/sites-available/svn.conf && \
echo " SVNPath /svn/repos/geumdo_repo" >> /etc/apache2/sites-available/svn.conf && \
echo " AuthType Basic" >> /etc/apache2/sites-available/svn.conf && \
echo " AuthName \"Subversion Repository\"" >> /etc/apache2/sites-available/svn.conf && \
echo " AuthUserFile /etc/apache2/dav_svn.passwd" >> /etc/apache2/sites-available/svn.conf && \
echo " Require valid-user" >> /etc/apache2/sites-available/svn.conf && \
echo "</Location>" >> /etc/apache2/sites-available/svn.conf
# SET LOCALE
RUN echo "LANG=ko_KR.UTF-8" >> /etc/default/locale && \
echo "LC_MESSAGES=ko_KR.UTF-8" >> /etc/default/locale
# Create SVN repository user
RUN htpasswd -cmb /etc/apache2/dav_svn.passwd gds !@#gds$%^
# Enable Apache SVN module
RUN a2enmod dav
RUN a2enmod dav_svn
# wget tomcat8.5.latest(tomcat 사양에 따라 dist 변경 필요)
RUN wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.98/bin/apache-tomcat-8.5.98.tar.gz
RUN tar -xf apache-tomcat-8.5.98.tar.gz -C /usr/local
RUN rm apache-tomcat-8.5.98.tar.gz
RUN mv /usr/local/apache-tomcat-8.5.98 /usr/local/tomcat
# java and tomcat path
RUN export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 >> /etc/profile
RUN export CATALINA_HOME=/usr/local/tomcat >> /etc/profile
RUN export CLASSPATH=.:$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/lib/jsp-api.jar:$CATALINA_HOME/lib/servlet-api.jar >> /etc/profile
RUN export LANG=ko_KR.UTF-8 >> /etc/profile
RUN bash -c 'source /etc/profile'
#run script folder and copy script
RUN mkdir /service_script
COPY start_service.sh /service_script
COPY setting.sql /service_script
RUN chmod +x /service_script/start_service.sh
# Expose port
EXPOSE 22 80 3306 3690 8080 9908
# Run SSH,DB,TOMCAT,SVN
CMD ["/service_script/start_service.sh"]
# 올인원 개발 서버 (Tomcat, MariaDB, SVN)
이 프로젝트는 단일 Docker 컨테이너 내에 Java 웹 개발 및 협업에 필요한 거의 모든 서비스를 통합하여 제공하는 "올인원(All-in-One)" 개발 환경입니다.
## 주요 기능
- **기반 환경**: Ubuntu 20.04
- **웹 애플리케이션 서버(WAS)**: Apache Tomcat 8.5.98 (OpenJDK 8, Maven 포함)
- **데이터베이스**: MariaDB Server
- **버전 관리 시스템**: Subversion (SVN), Apache(http) 및 svnserve(svn) 프로토콜 동시 지원
- **원격 접속**: OpenSSH Server
## 사전 요구사항
- [Docker](https://www.docker.com/get-started)
- [Docker Compose](https://docs.docker.com/compose/install/)
## 사용 방법
### 1. 서비스 시작 및 빌드
아래 스크립트를 실행하여 필요한 모든 Docker 볼륨을 생성하고, 이미지를 빌드한 뒤, 컨테이너를 시작합니다.
```bash
./rebuild_docker.sh
```
이 스크립트는 `dbdata`, `svndata` 등 7개의 Docker 볼륨을 자동으로 생성하고 `docker-compose.yml` 설정에 따라 컨테이너를 백그라운드에서 실행합니다.
### 2. 웹 애플리케이션 배포
WAR 파일을 `wardata` 볼륨에 해당하는 Tomcat의 `webapps` 디렉토리에 복사하여 배포할 수 있습니다.
```bash
# 로컬의 my_app.war 파일을 컨테이너의 웹앱 디렉토리로 복사
docker cp my_app.war docker_all:/usr/local/tomcat/webapps/
```
## 서비스 접속 정보
| 서비스 | 호스트 포트 | 컨테이너 포트 | 주소 / 명령어 | 계정 | 비밀번호 |
|---|---|---|---|---|---|
| SSH | `2226` | `22` | `ssh root@<서버_IP> -p 2226` | `root` | `!@#gds$%^` |
| MariaDB | `33060`| `3306` | `<서버_IP>` | `root` | `fnxmdkagh` |
| Tomcat | `8083` | `8080` | `http://<서버_IP>:8083` | - | - |
| SVN (http) | `8086` | `80` | `http://<서버_IP>:8086/svn/geumdo_repo`| `gds` | `!@#gds$%^` |
| SVN (svn) | `3690` | `3690` | `svn://<서버_IP>/geumdo_repo` | (설정필요) | (설정필요) |
| SecureDB | `9908` | `9908`| (에이전트 연결 포트) | - | - |
**참고**: `svnserve` 프로토콜(`svn://`)을 통한 접속은 별도의 사용자/권한 설정 파일(`svnserve.conf`, `passwd`)을 `svndata` 볼륨에서 구성해야 할 수 있습니다.
## 데이터 영속성 (볼륨)
이 환경은 각 서비스의 데이터와 설정을 보존하기 위해 7개의 Docker 볼륨을 사용합니다.
- `dbdata`: MariaDB 데이터 파일
- `dbconfig`: MariaDB 설정 파일
- `wasconfig`: Tomcat 설정 파일
- `wardata`: Tomcat 웹 애플리케이션 (WAR 파일)
- `svndata`: SVN 저장소 데이터 (`geumdo_repo`)
- `data`: Java 팀 범용 데이터 저장용
- `securedb`: SecureDB 에이전트 데이터 저장용
\ No newline at end of file
version: '3'
services:
os:
build:
context: .
dockerfile: Dockerfile
container_name: docker_all
restart: always
ports:
- "2226:22" # SSH
- "3690:3690" # SVN
- "8086:80" # APACHE
- "8083:8080" # tomcat
- "33060:3306" #mariadb
- "9908:9908" #securedb agent
network_mode: bridge
volumes:
- dbdata:/var/lib/mysql
- dbconfig:/etc/mysql
- wasconfig:/usr/local/tomcat/conf
- data:/data #java팀 전용
- wardata:/usr/local/tomcat/webapps #default tomcat 경로 사용시
- svndata:/svn/repos/geumdo_repo #svn추가
- securedb:/securedb
volumes:
dbdata:
external: true
dbconfig:
external: true
wasconfig:
external: true
data:
external: true
wardata:
external: true
svndata:
external: true
securedb:
external: true
#!/bin/sh
# Check and create volumes if they don't exist
create_volume() {
docker volume inspect $1 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Volume '$1' already exists."
else
docker volume create --name=$1
echo "Volume '$1' created."
fi
}
create_volume svndata
create_volume dbdata
create_volume dbconfig
create_volume wasconfig
create_volume data
create_volume wardata
create_volume securedb
# Build Docker image with explicit build context and Dockerfile path
docker build -t docker_all_os .
# Run Docker Compose with a specific container name
docker-compose up -d
#원하는 루트 원격 계정 password 입력
grant all privileges on *.* to root@'%' identified by 'fnxmdkagh';
flush privileges;
#!/bin/bash
# SSH
/usr/sbin/sshd -D & sleep 5
# MariaDB 시작 (DB 실행 후 루트 원격 계정 생성을 위해 sleep)
service mysql start && sleep 5
# 루트 원격 계정 생성
mysql -u root -pfnxmdkagh < ./setting.sql && sleep 5
# apache 시작
service apache2 start && sleep 5
# Tomcat 시작
/usr/local/tomcat/bin/catalina.sh run && sleep 5
# SVN 시작
svnserve -d -r /svn/repos/geumdo_repo && sleep 5
# Service 재시작 시 Docker가 종료되지 않도록 대기
tail -f /dev/null
# os with ssh
# images
FROM centos:6.10
# clear yum cache
RUN rm -f /var/lib/rpm/__*
RUN yum clean all
RUN rm -rf /var/cache/yum
# make new repo with vault.centos
RUN mkdir -p /var/cache/yum/x86_64/6/base/
RUN mkdir -p /var/cache/yum/x86_64/6/extras/
RUN mkdir -p /var/cache/yum/x86_64/6/updates/
RUN echo "http://vault.centos.org/6.10/os/x86_64/" > /var/cache/yum/x86_64/6/base/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/extras/x86_64/" > /var/cache/yum/x86_64/6/extras/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/updates/x86_64/" > /var/cache/yum/x86_64/6/updates/mirrorlist.txt
#makecache
RUN yum makecache
# Update the system
RUN yum -y update
# Setting Utils
RUN yum install -y vim net-tools iputils wget tar curl glibc libstdc++ zip unzip scp
# Setting locale ko
RUN yum install -y glibc && \
localedef -i ko_KR -f UTF-8 ko_KR.UTF-8 && \
echo -e "# Setting Language(ko_KR.UTF-8)\nexport LANGUAGE=ko_KR.UTF-8\nexport LANG=ko_KR.UTF-8" >> /etc/profile
# Install OpenSSH Server
RUN yum install -y openssh-server openssh-clients
# Set up configuration for SSH
RUN mkdir /var/run/sshd
RUN echo 'root:!@#gds$%^' | chpasswd
RUN echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config
# SSH login fix. Otherwise, the user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
# mySQL install
RUN yum install -y mysql-server
# mySQL setting
RUN sed -ri 's/^#?bind-address\s+.*/bind-address = 0.0.0.0/' /etc/my.cnf
RUN echo default-character-set=utf8 >> /etc/my.cnf
RUN echo lower_case_table_names=1 >> /etc/my.cnf
RUN echo default-time-zone='+9:00' >> /etc/my.cnf
RUN echo skip-character-set-client-handshake >> /etc/my.cnf
#apache install
RUN yum install -y httpd
#php install
RUN yum install -y php php-mbstring php-pdo php-xml php-mysql
# run script folder and copy script
RUN mkdir /service_script
COPY start_service.sh /service_script
RUN rm /etc/httpd/conf/httpd.conf
RUN rm /etc/ssh/sshd_config
RUN rm /etc/php.ini
RUN rm /etc/my.cnf
COPY httpd.conf /etc/httpd/conf
COPY sshd_config /etc/ssh/
COPY php.ini /etc
COPY my.cnf /etc
COPY setting.sql /service_script
COPY dump.sql /service_script
RUN chmod +x /service_script/start_service.sh
# Expose port
EXPOSE 22 3306 80
# Run SSH, DB, APACHE
CMD ["/service_script/start_service.sh"]
# os with ssh
# images
FROM centos:6.10
RUN yum repolist
RUN echo "http://vault.centos.org/6.10/os/x86_64/" > /var/cache/yum/x86_64/6/base/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/extras/x86_64/" > /var/cache/yum/x86_64/6/extras/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/updates/x86_64/" > /var/cache/yum/x86_64/6/updates/mirrorlist.txt
# Update the system and install packages
RUN yum -y update && \
yum install -y vim net-tools iputils wget tar curl glibc openssh-server mysql-server httpd \
php php-mbstring php-pdo php-xml php-mysql
# Setting locale ko
RUN yum install -y glibc && \
localedef -i ko_KR -f UTF-8 ko_KR.UTF-8 && \
echo -e "# Setting Language(ko_KR.UTF-8)\nexport LANGUAGE=ko_KR.UTF-8\nexport LANG=ko_KR.UTF-8" >> /etc/profile
# Install OpenSSH Server
RUN mkdir /var/run/sshd && \
echo 'root:!@#gds$%^' | chpasswd && \
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd && \
echo "export VISIBLE=now" >> /etc/profile
# mySQL setting
RUN sed -ri 's/^#?bind-address\s+.*/bind-address = 0.0.0.0/' /etc/my.cnf && \
echo default-character-set=utf8 >> /etc/my.cnf && \
echo lower_case_table_names=1 >> /etc/my.cnf && \
echo default-time-zone='+9:00' >> /etc/my.cnf && \
echo skip-character-set-client-handshake >> /etc/my.cnf
#apache install
RUN yum install -y httpd
# Copy configuration files and scripts
COPY httpd.conf sshd_config php.ini my.cnf /etc/
COPY start_service.sh setting.sql dump.sql /service_script/
RUN chmod +x /service_script/start_service.sh
# Expose port
EXPOSE 22 3306 80
# Run SSH, DB, APACHE
CMD ["/bin/bash", "/service_script/start_service.sh"]
# CentOS 6 APM 서버 환경 (DB 복원 기능 포함)
이 프로젝트는 CentOS 6.10을 기반으로 하는 APM (Apache, PHP, MySQL) 스택과 SSH 서버를 Docker를 사용하여 구축합니다. 특히, 컨테이너 생성 시 대용량 SQL 덤프 파일(`dump.sql`)을 자동으로 복원하여 특정 데이터베이스 상태를 재현하는 것을 주 목적으로 합니다.
이 폴더에는 두 가지 유사한 환경 설정(`docker-compose.yml`, `docker-compose-centos.yml`)이 포함되어 있습니다.
## 환경 1: `docker-compose.yml` (주력 환경)
### 주요 기능
- **기반 환경**: CentOS 6.10, Apache, PHP, MySQL, OpenSSH
- **DB 자동 복원**: 컨테이너 시작 시 `/service_script/dump.sql` 파일을 MySQL에 자동으로 임포트합니다.
- **소스 코드 마운트**: 호스트의 `/webFolder5.6/jobtp` 디렉토리를 웹 소스 경로로 사용합니다.
- **데이터 영속성**: DB 데이터, 설정 등을 Docker 볼륨으로 관리합니다.
### 사전 요구사항
- [Docker](https://www.docker.com/get-started)
- [Docker Compose](https://docs.docker.com/compose/install/)
- 호스트에 웹 소스 코드 디렉토리(`/webFolder5.6/jobtp`)가 존재해야 합니다.
### 사용 방법
`rebuild_docker.sh` 스크립트가 제공되지만, `docker-compose.yml`에 정의된 볼륨 이름과 스크립트가 생성하는 볼륨 이름이 달라 오류를 일으킬 수 있습니다. 아래의 수동 절차를 권장합니다.
**1. 볼륨 생성**
```bash
docker volume create dbdata_tp
docker volume create dbconfig_tp
docker volume create apconfig_tp
docker volume create mailerdata
```
**2. 빌드 및 시작**
```bash
# -f 옵션으로 사용할 compose 파일을 명시
docker-compose -f docker-compose.yml up -d --build
```
컨테이너가 시작되면 `start_service.sh` 스크립트가 실행되어 서비스 시작 및 DB 복원을 자동으로 수행합니다. (DB 복원에는 시간이 걸릴 수 있습니다.)
### 서비스 접속 정보
| 서비스 | 호스트 포트 | 컨테이너 포트 | 주소 / 명령어 | 계정 | 비밀번호 |
|---|---|---|---|---|---|
| SSH | `2227` | `22` | `ssh root@<서버_IP> -p 2227` | `root` | `!@#gds$%^` |
| Apache | `8084` | `80` | `http://<서버_IP>:8084` | - | - |
| MySQL | `33061`| `3306` | `<서버_IP>` | `root` | `!@#gds$%^` |
---
## 환경 2: `docker-compose-centos.yml` (변형 환경)
이 환경은 환경 1과 거의 동일하지만, 컨테이너 이름(`docker_jobtp`)과 사용하는 볼륨 이름(`dbdata_jobtp` 등)이 다릅니다.
### 사용 방법
```bash
# 1. 볼륨 생성
docker volume create dbdata_jobtp
docker volume create dbconfig_jobtp
docker volume create apconfig_jobtp
# 2. 빌드 및 시작
docker-compose -f docker-compose-centos.yml up -d --build
```
**참고**: `rebuild_docker.sh` 스크립트는 이 환경의 볼륨 이름(`dbdata_jobtp` 등)을 생성하지만, `docker-compose.yml`(환경 1)을 실행하도록 되어 있어 그대로 사용하면 오류가 발생합니다. 스크립트를 사용하려면 내부의 `docker-compose up -d` 부분을 `docker-compose -f docker-compose-centos.yml up -d`로 수정해야 합니다.
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment