Skip to content

Commit f5898eb

Browse files
authored
chore: Add suporte docker (#1)
1 parent a660d64 commit f5898eb

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed

.dockerignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ignore .git and .cache folders
2+
.cache*
3+
4+
# ignore all *.class files in all folders, including build root
5+
**/*.class
6+
7+
# ignore all markdown files (md) beside all README*.md other than README-secret.md
8+
*.md
9+
!README*.md
10+
README-secret.md
11+
12+
# ignore
13+
*Dockerfile*
14+
*docker-compose*
15+
node_modules
16+
.env*

Dockerfile.backend

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM node:16.14-slim
2+
3+
LABEL version="1.0.0" description="WPPconnectLinkPreview" maintainer="Alan Martines<[email protected]>"
4+
5+
RUN mkdir -p /home/wa-js-api-server
6+
7+
WORKDIR /home/wa-js-api-server
8+
9+
RUN apt-get update && \
10+
apt-get upgrade -y && \
11+
apt-get install -y \
12+
git \
13+
curl \
14+
yarn \
15+
wget
16+
17+
COPY . .
18+
19+
RUN git pull && \
20+
npm install && \
21+
npm run build
22+
23+
EXPOSE 8000/tcp
24+
25+
CMD [ "node", "--trace-warnings", "dist/server.js" ]
26+
27+
## Acessar bash do container
28+
# docker exec -it <container id> /bin/sh
29+
# docker exec -it <container id> /bin/bash
30+
31+
## Logs do container
32+
# docker logs -f --tail 1000 WPPconnectLinkPreview
33+
34+
## Removendo todos os containers e imagens de uma só vez
35+
# docker rm $(docker ps -qa)
36+
37+
## Removendo todas as imagens de uma só vez
38+
# docker rmi $(docker images -aq)
39+
40+
## Removendo imagens
41+
# docker rmi <REPOSITORY>
42+
# docker rmi <IMAGE ID>
43+
44+
## Como obter o endereço IP de um contêiner Docker do host
45+
# https://stack.desenvolvedor.expert/appendix/docker/rede.html
46+
# docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <IMAGE ID>

README.md

+42
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,48 @@ npm run build
5050
node ./dist/server.js
5151
```
5252

53+
## Docker-Compose
54+
55+
```bash
56+
# checkout the project
57+
git clone https://github.com/wppconnect-team/wa-js-api-server.git
58+
59+
# enter in the folder
60+
cd wa-js-api-server
61+
62+
# if you want to change some configuration, you can set en ENVIRONMENT variables or copy the .env to .env.local
63+
# cp .env .env.local
64+
65+
# create container
66+
docker-compose -f docker-compose.lpwp.yml up --build -d
67+
```
68+
69+
## Dockerfile
70+
71+
```bash
72+
# checkout the project
73+
git clone https://github.com/wppconnect-team/wa-js-api-server.git
74+
75+
# enter in the folder
76+
cd wa-js-api-server
77+
78+
# create image
79+
docker build -t wppconnect-team/wa-js-api-server:1.0.0 -f Dockerfile.backend .
80+
81+
# create container
82+
# if you want to change some setting you can set ENVIRONMENT variables
83+
docker run -d -p 8000:8000 --name WPPconnectLinkPreview \
84+
--restart=always \
85+
-e NODE_ENV=production \
86+
-e PORT=8000 \
87+
-e LOG_FORMAT=combined \
88+
-e LOG_DIR='./logs' \
89+
-e ORIGIN='https://web.whatsapp.com' \
90+
-e CACHE_MAX_ITEMS=500 \
91+
-e CACHE_MAX_SIZE=104857600 \
92+
-e CACHE_TTL=3600000 \
93+
wppconnect-team/wa-js-api-server:1.0.0
94+
```
5395
## License
5496

5597
Copyright 2021 WPPConnect Team

docker-compose.lpwp.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: "3.9"
2+
services:
3+
backend:
4+
container_name: WPPconnectLinkPreview
5+
hostname: WPPconnectLinkPreview
6+
network_mode: bridge
7+
image: wppconnect-team/wa-js-api-server:1.0.0
8+
build:
9+
context: .
10+
dockerfile: Dockerfile.backend
11+
restart: always
12+
environment:
13+
NODE_ENV: production
14+
PORT: 8000
15+
LOG_FORMAT: ${LOG_FORMAT:-'combined'}
16+
LOG_DIR: ${LOG_DIR:-'./logs'}
17+
ORIGIN: ${ORIGIN:-'https://web.whatsapp.com'}
18+
CACHE_MAX_ITEMS: ${CACHE_MAX_ITEMS:-500}
19+
CACHE_MAX_SIZE: ${CACHE_MAX_SIZE:-104857600}
20+
CACHE_TTL: ${CACHE_TTL:-3600000}
21+
ports:
22+
- ${PORT:-8000}:8000
23+
24+
#
25+
# docker-compose up -d
26+
# docker-compose -f docker-compose.lpwp.yml up --build -d
27+
#

0 commit comments

Comments
 (0)