Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 2bb8e02

Browse files
committed
added docker-compose and modified Dockerfile
1 parent 2ae30bd commit 2bb8e02

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ RUN chmod -R a-w /usr/local/lib/python3.8 && \
2828
# Switch to non-root user
2929
USER appuser
3030

31+
# Expose port 5000
32+
EXPOSE 5000
33+
3134
# Run the application
32-
CMD ["python", "pastebin.py"]
35+
CMD ["flask", "run", "--host=0.0.0.0"]
3336

3437
# Note: This Dockerfile implements several security measures.
3538
# For full details on security practices, please refer to SECURITY.md

docker-compose.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: '3.8' # Specify the Docker Compose version
2+
3+
services:
4+
pastebin:
5+
user: appuser # Rule 2. Run as a non-root user
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
env_file:
10+
- .env_file
11+
ports:
12+
- "5000:5000"
13+
volumes:
14+
- .:/app:ro # Mount the current directory to /app in the container as read-only
15+
restart: unless-stopped
16+
17+
# Rule 7. Resource Limits
18+
deploy:
19+
resources:
20+
limits:
21+
cpus: "0.5" # Limit container to 50% of a CPU
22+
memory: "512M" # Limit container memory to 512MB
23+
24+
# Rule 8. Read-Only Filesystem
25+
read_only: true # Mount the container's filesystem as read-only
26+
27+
# Rule 3. Drop All Capabilities
28+
cap_drop:
29+
- ALL
30+
31+
# Rule 4. Prevent the container from gaining new privileges
32+
security_opt:
33+
- no-new-privileges:true
34+
35+
36+
# 8. Logging Configuration
37+
logging:
38+
driver: "json-file"
39+
options:
40+
max-size: "10m"
41+
max-file: "3"
42+
43+
44+
# Network Configuration
45+
networks:
46+
pastebin_network:
47+
driver: bridge

0 commit comments

Comments
 (0)