jonathanjordan21 commited on
Commit
8324a5f
·
verified ·
1 Parent(s): ed65a07

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -142
Dockerfile CHANGED
@@ -1,154 +1,31 @@
1
- # Use an appropriate base image
2
- FROM ubuntu:20.04
3
 
4
- # Install necessary packages
5
- RUN apt-get update && apt-get install -y \
6
- curl \
7
- docker.io \
8
- && rm -rf /var/lib/apt/lists/*
9
-
10
- # Create the necessary directories
11
  RUN mkdir -p /var/lib/milvus /milvus/configs
12
 
13
- # Create the configuration files
14
- RUN cat << EOF > /milvus/configs/embedEtcd.yaml
15
- listen-client-urls: http://0.0.0.0:2379
16
  advertise-client-urls: http://0.0.0.0:2379
17
  quota-backend-bytes: 4294967296
18
  auto-compaction-mode: revision
19
- auto-compaction-retention: '1000'
20
- EOF
21
-
22
- RUN cat << EOF > /milvus/configs/user.yaml
23
- # Extra config to override default milvus.yaml
24
- EOF
25
-
26
- # Create the Bash script directly in the Dockerfile
27
- RUN cat << 'EOF' > /usr/local/bin/start_milvus.sh
28
- #!/bin/bash
29
-
30
- run_embed() {
31
- sudo docker run -d \
32
- --name milvus-standalone \
33
- --security-opt seccomp:unconfined \
34
- -e ETCD_USE_EMBED=true \
35
- -e ETCD_DATA_DIR=/var/lib/milvus/etcd \
36
- -e ETCD_CONFIG_PATH=/milvus/configs/embedEtcd.yaml \
37
- -e COMMON_STORAGETYPE=local \
38
- -v /var/lib/milvus:/var/lib/milvus \
39
- -v /milvus/configs/embedEtcd.yaml:/milvus/configs/embedEtcd.yaml \
40
- -v /milvus/configs/user.yaml:/milvus/configs/user.yaml \
41
- -p 19530:19530 \
42
- -p 9091:9091 \
43
- -p 2379:2379 \
44
- --health-cmd="curl -f http://localhost:9091/healthz" \
45
- --health-interval=30s \
46
- --health-start-period=90s \
47
- --health-timeout=20s \
48
- --health-retries=3 \
49
- milvusdb/milvus:v2.4.5 \
50
- milvus run standalone 1> /dev/null
51
- }
52
-
53
- wait_for_milvus_running() {
54
- echo "Wait for Milvus Starting..."
55
- while true
56
- do
57
- res=$(sudo docker ps|grep milvus-standalone|grep healthy|wc -l)
58
- if [ $res -eq 1 ]
59
- then
60
- echo "Start successfully."
61
- echo "To change the default Milvus configuration, add your settings to the user.yaml file and then restart the service."
62
- break
63
- fi
64
- sleep 1
65
- done
66
- }
67
-
68
- start() {
69
- res=$(sudo docker ps|grep milvus-standalone|grep healthy|wc -l)
70
- if [ $res -eq 1 ]
71
- then
72
- echo "Milvus is running."
73
- exit 0
74
- fi
75
-
76
- res=$(sudo docker ps -a|grep milvus-standalone|wc -l)
77
- if [ $res -eq 1 ]
78
- then
79
- sudo docker start milvus-standalone 1> /dev/null
80
- else
81
- run_embed
82
- fi
83
-
84
- if [ $? -ne 0 ]
85
- then
86
- echo "Start failed."
87
- exit 1
88
- fi
89
-
90
- wait_for_milvus_running
91
- }
92
-
93
- stop() {
94
- sudo docker stop milvus-standalone 1> /dev/null
95
-
96
- if [ $? -ne 0 ]
97
- then
98
- echo "Stop failed."
99
- exit 1
100
- fi
101
- echo "Stop successfully."
102
-
103
- }
104
-
105
- delete() {
106
- res=$(sudo docker ps|grep milvus-standalone|wc -l)
107
- if [ $res -eq 1 ]
108
- then
109
- echo "Please stop Milvus service before delete."
110
- exit 1
111
- fi
112
- sudo docker rm milvus-standalone 1> /dev/null
113
- if [ $? -ne 0 ]
114
- then
115
- echo "Delete failed."
116
- exit 1
117
- fi
118
- sudo rm -rf /var/lib/milvus
119
- sudo rm -rf /milvus/configs/embedEtcd.yaml
120
- sudo rm -rf /milvus/configs/user.yaml
121
- echo "Delete successfully."
122
- }
123
 
124
- case $1 in
125
- restart)
126
- stop
127
- start
128
- ;;
129
- start)
130
- start
131
- ;;
132
- stop)
133
- stop
134
- ;;
135
- delete)
136
- delete
137
- ;;
138
- *)
139
- echo "please use bash start_milvus.sh restart|start|stop|delete"
140
- ;;
141
- esac
142
- EOF
143
 
144
- # Make the script executable
145
- RUN chmod +x /usr/local/bin/start_milvus.sh
 
 
 
146
 
147
- # Expose the necessary ports
148
  EXPOSE 19530 9091 2379
149
 
150
- # Set the entrypoint to the script
151
- ENTRYPOINT ["/usr/local/bin/start_milvus.sh"]
 
152
 
153
- # Default command to start the service
154
- CMD ["start"]
 
1
+ # Use the official Milvus image as the base image
2
+ FROM milvusdb/milvus:v2.4.5
3
 
4
+ # Create necessary directories
 
 
 
 
 
 
5
  RUN mkdir -p /var/lib/milvus /milvus/configs
6
 
7
+ # Create the embedEtcd.yaml file
8
+ RUN echo "listen-client-urls: http://0.0.0.0:2379
 
9
  advertise-client-urls: http://0.0.0.0:2379
10
  quota-backend-bytes: 4294967296
11
  auto-compaction-mode: revision
12
+ auto-compaction-retention: '1000'" > /milvus/configs/embedEtcd.yaml
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ # Create the user.yaml file
15
+ RUN echo "# Extra config to override default milvus.yaml" > /milvus/configs/user.yaml
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ # Set environment variables
18
+ ENV ETCD_USE_EMBED=true
19
+ ENV ETCD_DATA_DIR=/var/lib/milvus/etcd
20
+ ENV ETCD_CONFIG_PATH=/milvus/configs/embedEtcd.yaml
21
+ ENV COMMON_STORAGETYPE=local
22
 
23
+ # Expose necessary ports
24
  EXPOSE 19530 9091 2379
25
 
26
+ # Health check configuration
27
+ HEALTHCHECK --interval=30s --timeout=20s --start-period=90s --retries=3 \
28
+ CMD curl -f http://localhost:9091/healthz || exit 1
29
 
30
+ # Command to run Milvus standalone
31
+ CMD ["milvus", "run", "standalone"]