본문 바로가기

Game/UMPC

[RoadCraft] 세이브파일 에디터 서버 구축

아스팔트 공사가 참 힘들고 돈이 많이 필요하다는 것을 깨닫게 해준 게임...

 

 

소스 다운로드

https://github.com/forhekset/roadcraft-completesave-streamlit

 

GitHub - forhekset/roadcraft-completesave-streamlit: Roadcraft completesave editor with streamlit

Roadcraft completesave editor with streamlit. Contribute to forhekset/roadcraft-completesave-streamlit development by creating an account on GitHub.

github.com

 

원제작자의 소스는 세이브파일 수정 후 저장할 때 에러가 있어서 포크 후 수정하였다.

git clone https://github.com/forhekset/roadcraft-completesave-streamlit.git

 

 

해당 디렉토리로 이동

cd roadcraft-completesave-streamlit

 

Python3 가상 환경 설치 및 활성화

python3 -m venv venv
source venv/bin/activate

 

가상 환경이 활성화 되면 프롬프트 앞에 (venv) 가 붙게 된다.

가상환경에 Streamlit 라이브러리를 설치한다. (약 390MB)

(venv) razor1911@ubuntu:~/roadcraft-completesave-streamlit$ pip install streamlit
Collecting streamlit
  Downloading streamlit-1.46.1-py3-none-any.whl (10.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.1/10.1 MB 74.0 MB/s eta 0:00:00
Collecting typing-extensions<5,>=4.4.0
  Downloading typing_extensions-4.14.0-py3-none-any.whl (43 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.8/43.8 KB 4.3 MB/s eta 0:00:00
................
................

 

실행해본다.

(venv) razor1911@ubuntu:~/roadcraft-completesave-streamlit$ streamlit run roadcraft_streamlit.py

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to false.


  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://10.1.0.4:8501
  External URL: http://xxx.xxx.xxx.xxx:8501

 

일단 다시 종료 후, 외부에서 안전하게 접근하기 위해 앞단에 nginx 를 설정하기 위해  설정 파일을 하나 추가해준다. 

(venv) razor1911@ubuntu:~/roadcraft-completesave-streamlit$ mkdir -p .streamlit
(venv) razor1911@ubuntu:~/roadcraft-completesave-streamlit$ nano .streamlit/config.toml

 

config.toml

[server]
enableCORS = false

 

이제 웹 어플리케이션을 백그라운드로 실행해주고 venv 터미널 세션에서 나온다.

(venv) razor1911@ubuntu:~/roadcraft-completesave-streamlit$ nohup streamlit run roadcraft_streamlit.py &
[1] 1334690
(venv) razor1911@ubuntu:~/roadcraft-completesave-streamlit$ nohup: ignoring input and appending output to 'nohup.out'

(venv) razor1911@ubuntu:~/roadcraft-completesave-streamlit$ deactivate
razor1911@ubuntu:~/roadcraft-completesave-streamlit$

 

 

nginx 설정을 적용해준다.

외부 접근을 제어하기 위해 앞단에 nginx 인증을 추가하였다.

server {
  server_name <도메인>;

  location / {
    auth_basic "Restricted Content";
    auth_basic_user_file /etc/nginx/.htpasswd;
    proxy_pass http://localhost:8501;
    proxy_pass_header Server;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port "<nginx 포트>";
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }

  listen <nginx 포트> ssl; # managed by Certbot
  ssl_certificate /etc/letsencrypt..../fullchain.pem; # Let's Encrypt 인증서 경로
  ssl_certificate_key /etc/letsencrypt..../privkey.pem; # Let's Encrypt 개인 키 경로
}

 

 

 

nginx 프록시에 패스워드를 추가하는 방법은 아래 글을 참고하면 된다.

 

changedetection.io 셀프 호스팅 하기

사이트 변경사항을 추적하는 서비스를 클라우드 인스턴스에 안전하게 구축해보자. 먼저 이미지를 받아서 올려본다.git clone https://github.com/dgtlmoon/changedetection.io.gitcd changedetection.iosudo docker-compose u

blog.razor1911.xyz

 

접속 확인