-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
executable file
·207 lines (185 loc) · 6.26 KB
/
Copy pathdocker-compose.yml
File metadata and controls
executable file
·207 lines (185 loc) · 6.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/env -S bash -x -c 'docker compose --file docker-compose.yml up --detach'
#region commands -----------------------------------------------------------------------------------
# 1. Create the containers and the services in the background
#$ docker compose --file docker-compose.yml up --detach
# 2. Test database connections
#$ docker exec -it petl-postgres psql -U petl --dbname=petl
#$ docker exec -it petl-msyql mysql --user=petl --database=petl --password=test
# 3. Run a shell inside the python sandbox container
#$ docker exec --interactive --tty --privileged petl-python27 /bin/bash
#$ docker exec -it --privileged petl-python3x /bin/bash
# 5. Stop the services and remove the containers
#$ docker compose --file docker-compose.yml down --remove-orphans -v --rmi local
#endregion -----------------------------------------------------------------------------------------
#region file/db services ---------------------------------------------------------------------------
---
services:
postgres:
container_name: petl-postgres
hostname: petl_postgres
image: postgres:latest
environment:
- POSTGRES_USER=petl
- POSTGRES_PASSWORD=test
- POSTGRES_DB=petl
- POSTGRES_HOST_AUTH_METHOD=password
ports:
- "5432:5432/tcp"
restart: "unless-stopped"
stdin_open: true
tty: true
healthcheck:
test:
[
"CMD",
"psql",
"--host=localhost",
"--username=petl",
"--dbname=petl",
"-c",
"select 1 as ok",
]
interval: 20s
timeout: 10s
retries: 5
start_period: 2s
networks:
- petl_network
mysql:
container_name: petl-mysql
hostname: petl_mysql
image: mysql:latest
ports:
- "3306:3306/tcp"
- "33060:33060/tcp"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_DATABASE: "petl"
MYSQL_USER: "petl"
MYSQL_PASSWORD: "test"
MYSQL_ROOT_PASSWORD: "pass0"
restart: "unless-stopped"
stdin_open: true
tty: true
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 20s
timeout: 10s
retries: 5
start_period: 2s
networks:
- petl_network
samba:
container_name: petl-samba
hostname: petl_samba
image: dperson/samba
ports:
- "137:137/udp"
- "138:138/udp"
- "139:139/tcp"
- "445:445/tcp"
tmpfs:
- /tmp
restart: unless-stopped
stdin_open: true
tty: true
volumes:
- /mnt:/mnt:z
- /mnt2:/mnt2:z
command: '-s "public;/mnt;yes;no;yes;all" -s "mount2;/mnt2" -u "petl;test" -p'
networks:
- petl_network
sftp:
container_name: petl-sftp
hostname: petl_sftp
image: atmoz/sftp
ports:
- "2244:22/tcp"
tmpfs:
- /tmp
restart: unless-stopped
stdin_open: true
tty: true
command: "petl:test:::public"
networks:
- petl_network
#endregion -----------------------------------------------------------------------------------------
#region python sandbox -----------------------------------------------------------------------------
python3x:
container_name: petl-python3x
hostname: petl_py3x
# image: python:slim
environment:
- PYTHON3_IMAGE_TAG=${PYTHON3_IMAGE_TAG:-slim}
- PYTHONTRACEMALLOC=1
- POSTGRES_HOST=petl_postgres
- MYSQL_HOST=petl_mysql
- PETL_TEST_SMB=smb://WORKGROUP;petl:test@petl_samba/public/
- PETL_TEST_SFTP=sftp://petl:test@petl_sftp:2244/public/
build:
context: .
dockerfile_inline: |
FROM python:${PYTHON3_IMAGE_TAG:-slim}
RUN apt-get update
RUN apt-get install -y postgresql-client default-mysql-client smbclient openssh-client
RUN apt-get install -y gcc git
RUN python -m pip install --upgrade pip
RUN mkdir -p /app
RUN mkdir -p /req
COPY requirements-*.txt /req/
RUN python -m pip install -r req/requirements-tests.txt -r req/requirements-database.txt -r req/requirements-formats.txt -r req/requirements-remote.txt -r req/requirements-docs.txt -r req/requirements-linting.txt
# Keeps the container running forever
command: tail -f /dev/null
restart: unless-stopped
stdin_open: true
tty: true
# mounts the repository souce code into the container
volumes:
- .:/app
working_dir: /app
networks:
- petl_network
python27:
container_name: petl-python27
hostname: petl_py27
# image: python:2.7.18-slim
environment:
- PYTHON2_IMAGE_TAG=${PYTHON2_IMAGE_TAG:-2.7.18-slim}
- PYTHONTRACEMALLOC=1
- POSTGRES_HOST=petl_postgres
- MYSQL_HOST=petl_mysql
- PETL_TEST_SMB=smb://WORKGROUP;petl:test@petl_samba/public/
- PETL_TEST_SFTP=sftp://petl:test@petl_sftp:2244/public/
build:
context: .
dockerfile_inline: |
FROM python:${PYTHON2_IMAGE_TAG:-2.7.18-slim}
RUN sed -i 's/deb.debian.org/archive.debian.org/g' /etc/apt/sources.list \
&& sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list \
&& sed -i '/buster-updates/d' /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y postgresql-client default-mysql-client smbclient openssh-client
RUN apt-get install -y gcc git
RUN python -m pip install --upgrade pip
RUN mkdir -p /app
RUN apt-get install -y default-libmysqlclient-dev
RUN mkdir -p /req
COPY requirements-*.txt /req/
RUN python -m pip install -r req/requirements-tests.txt -r req/requirements-database.txt -r req/requirements-formats.txt -r req/requirements-remote.txt -r req/requirements-docs.txt
# Keeps the container running forever
command: tail -f /dev/null
restart: unless-stopped
stdin_open: true
tty: true
# mounts the repository souce code into the container
volumes:
- .:/app
working_dir: /app
networks:
- petl_network
#endregion -----------------------------------------------------------------------------------------
#region other settings -----------------------------------------------------------------------------
networks:
petl_network:
driver: bridge
#endregion -----------------------------------------------------------------------------------------