0duaansa commited on
Commit
5992270
·
verified ·
1 Parent(s): 0743fd4

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +56 -0
Dockerfile ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Sử dụng base image
2
+ FROM buildpack-deps:22.04-curl
3
+
4
+ # Cài đặt các công cụ cần thiết để biên dịch Redis và Python
5
+ RUN apt-get update && apt-get install -y --no-install-recommends \
6
+ build-essential \
7
+ curl \
8
+ wget \
9
+ net-tools \
10
+ vim \
11
+ locales \
12
+ python3 \
13
+ python3-pip \
14
+ && rm -rf /var/lib/apt/lists/*
15
+
16
+ # Cài đặt Redis phiên bản mới nhất
17
+ ARG REDIS_VERSION=7.0.12
18
+ RUN wget http://download.redis.io/releases/redis-${REDIS_VERSION}.tar.gz \
19
+ && tar xzf redis-${REDIS_VERSION}.tar.gz \
20
+ && rm redis-${REDIS_VERSION}.tar.gz \
21
+ && cd redis-${REDIS_VERSION} \
22
+ && make && make install \
23
+ && cd .. && rm -rf redis-${REDIS_VERSION}
24
+
25
+ # Cài đặt Flask và các thư viện Python cần thiết
26
+ RUN pip3 install --no-cache-dir flask redis
27
+
28
+ # Sao chép file cấu hình Redis
29
+ COPY redis.conf /etc/redis/redis.conf
30
+
31
+ # Tạo người dùng và thư mục làm việc
32
+ ARG USERNAME=redisuser
33
+ ARG USER_UID=1000
34
+ ARG USER_GID=$USER_UID
35
+
36
+ RUN groupadd --gid $USER_GID $USERNAME \
37
+ && useradd --uid $USER_UID --gid $USERNAME -m -s /bin/bash $USERNAME \
38
+ && mkdir -p /data && chown $USERNAME:$USERNAME /data
39
+
40
+ USER $USERNAME
41
+ WORKDIR /data
42
+
43
+ # Sao chép mã nguồn web app
44
+ COPY app.py /data/app.py
45
+
46
+ # Cấu hình biến môi trường
47
+ ENV LANG=C.UTF-8 \
48
+ LC_ALL=C.UTF-8 \
49
+ HOME=/data \
50
+ REDIS_CONFIG_FILE=/etc/redis/redis.conf
51
+
52
+ # Expose cổng Redis và Flask
53
+ EXPOSE 6379 5000
54
+
55
+ # Command chạy Redis và web server song song
56
+ CMD ["bash", "-c", "redis-server /etc/redis/redis.conf & python3 /data/app.py"]