Skip to content

Commit 97506b2

Browse files
authored
Merge pull request #12 from CESNET/docker
Docker
2 parents 30bd56b + eb534fc commit 97506b2

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM python:3.11-slim
2+
3+
# System packages
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
git \
6+
curl \
7+
iputils-ping \
8+
xmlstarlet \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
WORKDIR /app
12+
13+
# Clone repo with scripts
14+
RUN git clone https://github.com/CESNET/DhusPytools.git .
15+
16+
# Python dependecies
17+
RUN pip install --no-cache-dir -r requirements.txt
18+
19+
# Copying entrypoint script that generates .netrc from .env variables
20+
COPY start_script.sh /app/start_script.sh
21+
RUN chmod +x /app/start_script.sh
22+
23+
# Setting up the entrypoint (this creates a .netrc) and then running our Python script.
24+
ENTRYPOINT ["/app/start_script.sh"]
25+
26+
# When the container starts, the Python script check_new_register_stac.py is run
27+
CMD ["python3", "/app/check_new_register_stac.py"]

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,25 @@ configurable parameters: `./register_stack.py -h`
3737

3838
**Authentication**: Basic auth is resolved automatically by the Requests library by reading a **~/.netrc** file. Make sure
3939
to set up the correct entries (Sentinel and STAC host URL) there.
40+
41+
# Docker
42+
1. create `.env` file - this file propagate variables to .netrc file in container
43+
example:
44+
```
45+
NETRC_MACHINE1=dhr1.cesnet.cz
46+
NETRC_LOGIN1=
47+
NETRC_PASSWORD1=
48+
49+
NETRC_MACHINE2=resto.c-scale.zcu.cz
50+
NETRC_LOGIN2=
51+
NETRC_PASSWORD2=
52+
```
53+
2. build and run with docker compose (have to run directly in directory)
54+
```
55+
docker compose build
56+
```
57+
```
58+
docker compose up
59+
```
60+
3. all files from /var/tmp/sentinel are in /mnt/data/var/tmp/sentinel
61+
- it can be change in ``` docker-compose.yaml```

docker-compose.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
app:
3+
image: dhuspytools:0.1
4+
build: .
5+
volumes:
6+
- /mnt/data/var/tmp/sentinel:/var/tmp/sentinel
7+
env_file:
8+
- path: ./.env
9+
required: true
10+

start_script.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -e
3+
4+
NETRC_FILE="/root/.netrc"
5+
6+
# Verify that all necessary variables are set for the first block
7+
if [ -z "$NETRC_MACHINE1" ] || [ -z "$NETRC_LOGIN1" ] || [ -z "$NETRC_PASSWORD1" ]; then
8+
echo "Pro první blok .netrc nejsou nastaveny všechny proměnné (NETRC_MACHINE1, NETRC_LOGIN1, NETRC_PASSWORD1)."
9+
exit 1
10+
fi
11+
12+
# Verify that all necessary variables are set for the second block
13+
if [ -z "$NETRC_MACHINE2" ] || [ -z "$NETRC_LOGIN2" ] || [ -z "$NETRC_PASSWORD2" ]; then
14+
echo "Pro druhý blok .netrc nejsou nastaveny všechny proměnné (NETRC_MACHINE2, NETRC_LOGIN2, NETRC_PASSWORD2)."
15+
exit 1
16+
fi
17+
18+
cat > "$NETRC_FILE" <<EOF
19+
machine ${NETRC_MACHINE1} login ${NETRC_LOGIN1} password ${NETRC_PASSWORD1}
20+
machine ${NETRC_MACHINE2} login ${NETRC_LOGIN2} password ${NETRC_PASSWORD2}
21+
EOF
22+
23+
chmod 600 "$NETRC_FILE"
24+
echo ".netrc vytvořen s dvěma bloky podle zadaného formátu."
25+
26+
# Executes the passed command (e.g. your main script)
27+
exec "$@"
28+

0 commit comments

Comments
 (0)