[refactor] プロジェクトのセキュリティとファイル構造の改善
Browse files以下の主な変更をマージしました:
1. **.gitignoreの更新**:
- `tmp_TimeLinR`と`custom_style.css`ファイルを追加し、不要なファイルのバージョン管理を回避。
2. **Dockerfileのセキュリティとユーザー設定の改善**:
- `USER`指令の順序を調整し、セキュリティ向上のために非rootユーザー`user`への切り替えを最適化。
- `/app`ディレクトリの所有権を`user`に設定し直し、セキュリティ強化を図りました。
3. **app.pyのカスタムCSSファイルパスの簡略化**:
- CSSファイルのパスを`./custom_style.css`に変更し、ファイル構造を簡素化しました。
4. **timeline_image.pngの最適化**:
- 画像ファイルのサイズを削減し、Webでのロード時間の短縮を実現しました。
これらの変更により、アプリケーションのセキュリティが向上し、ファイル管理が効率化され、ユーザー体験が改善されます。
- .gitignore +2 -1
- Dockerfile +5 -3
- app.py +1 -2
- timeline_image.png +2 -2
.gitignore
CHANGED
|
@@ -161,4 +161,5 @@ cython_debug/
|
|
| 161 |
|
| 162 |
SourceSageAssets/
|
| 163 |
memo.md
|
| 164 |
-
tmp_TimeLinR
|
|
|
|
|
|
| 161 |
|
| 162 |
SourceSageAssets/
|
| 163 |
memo.md
|
| 164 |
+
tmp_TimeLinR
|
| 165 |
+
custom_style.css
|
Dockerfile
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
-
|
| 4 |
-
USER user
|
| 5 |
-
|
| 6 |
|
|
|
|
| 7 |
WORKDIR /app
|
| 8 |
RUN chown -R user:user /app
|
| 9 |
|
|
@@ -23,4 +22,7 @@ EXPOSE 8501
|
|
| 23 |
# Set the PATH for Chromium
|
| 24 |
ENV CHROMIUM_PATH /usr/bin/chromium
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
CMD ["streamlit", "run", "app.py"]
|
|
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
+
USER root
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
WORKDIR /app
|
| 7 |
RUN chown -R user:user /app
|
| 8 |
|
|
|
|
| 22 |
# Set the PATH for Chromium
|
| 23 |
ENV CHROMIUM_PATH /usr/bin/chromium
|
| 24 |
|
| 25 |
+
RUN chown -R user:user /app
|
| 26 |
+
USER user
|
| 27 |
+
|
| 28 |
CMD ["streamlit", "run", "app.py"]
|
app.py
CHANGED
|
@@ -50,9 +50,8 @@ def generate_timeline(df, margin_coefficient):
|
|
| 50 |
return timeline_html
|
| 51 |
|
| 52 |
def create_custom_css(border_color, marker_color, box_background):
|
| 53 |
-
os.makedirs("./tmp_TimeLinR", exist_ok=True)
|
| 54 |
|
| 55 |
-
css_file_path = create_custom_css_file(border_color, marker_color, box_background, './
|
| 56 |
custom_css = load_css(css_file_path)
|
| 57 |
st.markdown(f'<style>{custom_css}</style>', unsafe_allow_html=True)
|
| 58 |
return custom_css
|
|
|
|
| 50 |
return timeline_html
|
| 51 |
|
| 52 |
def create_custom_css(border_color, marker_color, box_background):
|
|
|
|
| 53 |
|
| 54 |
+
css_file_path = create_custom_css_file(border_color, marker_color, box_background, './custom_style.css')
|
| 55 |
custom_css = load_css(css_file_path)
|
| 56 |
st.markdown(f'<style>{custom_css}</style>', unsafe_allow_html=True)
|
| 57 |
return custom_css
|
timeline_image.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|