File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -86,12 +86,15 @@ echo "1. Build the Docker image by running the following command:"
86
86
echo " sudo docker build -t telegrambot-openai-api ."
87
87
echo
88
88
echo " 2. After building the image, start the bot container using:"
89
- echo " sudo docker run --env-file .env -d telegrambot-openai-api"
89
+ echo " sudo docker run --env-file .env --name telegrambot-openai-api - d telegrambot-openai-api"
90
90
echo
91
91
echo " 3. Check the container status with:"
92
92
echo " sudo docker ps"
93
93
echo
94
- echo " 4. Stop the container with:"
94
+ echo " 4. Check the logs with:"
95
+ echo " sudo docker logs telegrambot-openai-api"
96
+ echo
97
+ echo " 5. Stop the container with:"
95
98
echo " sudo docker stop <container_id>"
96
99
echo
97
100
echo " After that, you're all set! Enjoy, and don't forget to start the repository if you like it. :-)"
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ CONTAINER_NAME=" telegrambot-openai-api"
4
+ IMAGE_NAME=" telegrambot-openai-api"
5
+
6
+ # Function to stop and remove existing container
7
+ cleanup () {
8
+ echo " Stopping container if it's running..."
9
+ sudo docker stop ${CONTAINER_NAME} || true
10
+
11
+ echo " Removing container if it exists..."
12
+ sudo docker rm ${CONTAINER_NAME} || true
13
+ }
14
+
15
+ # Function to build and run the container
16
+ deploy () {
17
+ echo " Building Docker image..."
18
+ sudo docker build --no-cache -t ${IMAGE_NAME} .
19
+ if [[ $? -ne 0 ]]; then
20
+ echo " Error: Docker image build failed."
21
+ exit 1
22
+ fi
23
+
24
+ echo " Running Docker container..."
25
+ sudo docker run --env-file .env --name ${CONTAINER_NAME} -d ${IMAGE_NAME}
26
+ if [[ $? -ne 0 ]]; then
27
+ echo " Error: Failed to run the Docker container."
28
+ exit 1
29
+ fi
30
+
31
+ echo " Deployment complete."
32
+ }
33
+
34
+ # Execute the functions
35
+ cleanup
36
+ deploy
You can’t perform that action at this time.
0 commit comments