Akane710 commited on
Commit
f681eec
·
verified ·
1 Parent(s): 6cd4f5b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -7
Dockerfile CHANGED
@@ -1,6 +1,7 @@
1
  ARG PYTHON_VERSION=3.12.1
2
  FROM python:${PYTHON_VERSION}-slim AS base
3
 
 
4
  RUN apt-get update && \
5
  apt-get install -y pipenv && \
6
  apt-get install -y \
@@ -13,22 +14,34 @@ RUN apt-get update && \
13
  git && \
14
  rm -rf /var/lib/apt/lists/*
15
 
 
16
  ENV PORT=7860
17
-
18
  ENV PIPENV_VENV_IN_PROJECT=1
19
 
20
- WORKDIR /app
 
 
21
 
22
- # COPY requirements.txt .
 
 
23
 
24
- # RUN pipenv install --dev --ignore-pipfile
 
25
 
26
- COPY . .
 
27
 
28
- EXPOSE 7860
 
29
  RUN pipenv run pip install -U pydantic
30
  RUN pipenv run pip install asyncio fastapi uvicorn requests cloudinary genshin
31
  RUN pipenv run pip install git+https://github.com/Akane7101/enkacard
32
  RUN pipenv run pip install git+https://github.com/Akane7101/StarRailCard
33
  RUN pipenv run pip install git+https://github.com/Akane7101/EnkaNetwork.py
34
- CMD [ "pipenv", "run", "python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "8", "--timeout-keep-alive", "600" ]
 
 
 
 
 
 
1
  ARG PYTHON_VERSION=3.12.1
2
  FROM python:${PYTHON_VERSION}-slim AS base
3
 
4
+ # Install system dependencies
5
  RUN apt-get update && \
6
  apt-get install -y pipenv && \
7
  apt-get install -y \
 
14
  git && \
15
  rm -rf /var/lib/apt/lists/*
16
 
17
+ # Set environment variables
18
  ENV PORT=7860
 
19
  ENV PIPENV_VENV_IN_PROJECT=1
20
 
21
+ # Create a non-root user and group
22
+ RUN groupadd -g 1000 appuser && \
23
+ useradd -m -u 1000 -g appuser appuser
24
 
25
+ # Set the working directory and adjust permissions
26
+ WORKDIR /app
27
+ RUN chown -R appuser:appuser /app
28
 
29
+ # Switch to the non-root user
30
+ USER appuser
31
 
32
+ # Copy application code
33
+ COPY --chown=appuser:appuser . .
34
 
35
+ # Install dependencies
36
+ RUN pipenv install --dev --ignore-pipfile
37
  RUN pipenv run pip install -U pydantic
38
  RUN pipenv run pip install asyncio fastapi uvicorn requests cloudinary genshin
39
  RUN pipenv run pip install git+https://github.com/Akane7101/enkacard
40
  RUN pipenv run pip install git+https://github.com/Akane7101/StarRailCard
41
  RUN pipenv run pip install git+https://github.com/Akane7101/EnkaNetwork.py
42
+
43
+ # Expose the application port
44
+ EXPOSE 7860
45
+
46
+ # Command to run the application
47
+ CMD ["pipenv", "run", "python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "8", "--timeout-keep-alive", "600"]