Skip to content

Commit

Permalink
Merge pull request #558 from MyElectricalData/feat/build-args
Browse files Browse the repository at this point in the history
Feat/build args
  • Loading branch information
m4dm4rtig4n authored Jul 29, 2024
2 parents 3c4b297 + 239c4f1 commit 299af44
Show file tree
Hide file tree
Showing 101 changed files with 9,018 additions and 6,369 deletions.
10 changes: 5 additions & 5 deletions .devcontainer/docker-compose.tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
ports:
- '8086:8086'
volumes:
- ./../data/influxdb:/var/lib/influxdb2
- ~/tmp/med/data/influxdb:/var/lib/influxdb2
healthcheck:
test: ["CMD", "curl", "-f", "http://influxdb:8086"]
interval: 25s
Expand All @@ -43,7 +43,7 @@ services:
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ${HOME}/.tmp/myelectridalcata/data/mosquitto:/data
- /tmp/med/data/mosquitto:/data
- ./../mosquitto:/mosquitto/config/
ports:
- 1883:1883
Expand All @@ -56,7 +56,7 @@ services:
links:
- mosquitto
volumes:
- ${HOME}/.tmp/myelectridalcata/data/:/mqtt-explorer/config
- /tmp/med/data/mqtt-explorer:/mqtt-explorer/config
ports:
- 4000:4000

Expand All @@ -73,7 +73,7 @@ services:
ports:
- "5432:5432"
volumes:
- ${HOME}/.tmp/myelectridalcata/data/postgresql/data:/var/lib/postgresql/data
- /tmp/med/data/postgresql:/var/lib/postgresql/data
- ./../init.sql:/docker-entrypoint-initdb.d/init.sql

mysql:
Expand All @@ -87,7 +87,7 @@ services:
ports:
- "3306:3306"
volumes:
- ${HOME}/.tmp/myelectridalcata/data/mysql/data:/var/lib/mysql
- /tmp/med/data/data/mysql/data:/var/lib/mysql

volumes:
mydata:
35 changes: 21 additions & 14 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "1.0.0",
"configurations": [
{
"name": "Python (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "/app/main.py",
"console": "integratedTerminal"
}
]
}
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
// Pointez pour afficher la description des attributs existants.
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Débogueur Python : Fichier actuel",
"env": {
"PYTHONPATH": "${workspaceFolder}/src",
"DEV": "true",
"DEBUG": "true"
},
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/src/main.py",
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/.env"
// "preLaunchTask": "select-environment-mock"
}
]
}
12 changes: 10 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true
"**/Thumbs.db": true,
".venv": true,
".pytest_cache": true
},
"hide-files.files": []
"hide-files.files": [
".venv",
".pytest_cache"
],
"yaml.schemas": {
"https://json.schemastore.org/yamllint.json": "file:///home/cvalentin/git/myelectricaldata/myelectricaldata_import/data/config.yaml"
}
}
32 changes: 25 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
FROM python:3.12.3-slim

ARG TARGETPLATFORM
ENV TARGETPLATFORM=$TARGETPLATFORM

ENV LANG fr_FR.UTF-8
ENV LC_ALL fr_FR.UTF-8
ENV TZ=Europe/Paris

RUN apt-get update && \
apt-get install -y \
locales \
git \
g++ \
gcc \
libpq-dev
RUN sed -i -e 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen
libpq-dev \
curl
RUN sed -i -e 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen
RUN dpkg-reconfigure --frontend=noninteractive locales
RUN rm -rf /var/lib/apt/lists/*

ENV LANG fr_FR.UTF-8
ENV LC_ALL fr_FR.UTF-8
ENV TZ=Europe/Paris

RUN pip install --upgrade pip pip-tools setuptools

# INSTALL RUST FOR ARMv7 and orjson lib
RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
apt install -y curl git build-essential libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf libdbus-1-dev libdbus-1-dev:armhf && \
curl -k -o rust-install.tar.gz https://static.rust-lang.org/dist/rust-1.78.0-armv7-unknown-linux-gnueabihf.tar.xz && \
tar -xvf rust-install.tar.gz && \
chmod +x rust-1.78.0-armv7-unknown-linux-gnueabihf/install.sh && \
./rust-1.78.0-armv7-unknown-linux-gnueabihf/install.sh; \
fi

COPY ./src /app

RUN pip install -r /app/requirements.txt

# REMOVE RUST
RUN /usr/local/lib/rustlib/uninstall.sh

RUN mkdir /data
RUN mkdir /log

Expand All @@ -42,4 +57,7 @@ LABEL \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}

# CLEAN
RUN rm -rf /var/lib/apt/lists/*

CMD ["python", "-u", "/app/main.py"]
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,10 @@ with open(f".env", 'w') as file:
file.write("\n".join(env))
endef
export set_env

######################################
## OPENTRACING DEV TOOLS
otel-collector: jaeger
jaeger: ## ▶ Run Jaeger (opentrace collector & UI) in local.
docker-compose -f toolbox/tools/jaeger.yaml up -d
@$(call title, "Jaeger is running on http://localhost:16686")
97 changes: 97 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
backend:
uri: sqlite:////data/myelectricaldata.db
gateway:
url: myelectricaldata.fr
ssl: true
home_assistant:
enable: false
discovery_prefix: homeassistant
home_assistant_ws:
enable: false
ssl: false
token: ''
url: ws://localhost:8123
purge: false
batch_size: 1000
max_date:
influxdb:
enable: false
scheme: http
hostname: localhost
port: 8086
token: my-token
org: myorg
bucket: mybucket
method: SYNCHRONOUS
timezone: UTC
wipe: false
batching_options:
batch_size: 1000
flush_interval: 1000
jitter_interval: 0
retry_interval: 5000
max_retry_time: '180_000'
max_retries: 5
max_retry_delay: '125_000'
exponential_base: 2
logging:
log_format: '%(asctime)s.%(msecs)03d - %(levelname)8s : %(message)s'
log_format_date: '%Y-%m-%d %H:%M:%S'
log2file: false
log_level: 20
debug: false
log_http: false
mqtt:
enable: false
hostname: localhost
port: 1883
username: ''
password: ''
prefix: myelectricaldata
client_id: myelectricaldata
retain: true
qos: 0
cert: false
myelectricaldata:
MON_POINT_DE_LIVRAISON:
enable: true
name: MON_POINT_DE_LIVRAISON
token: VOTRE_TOKEN_MYELECTRICALDATA
cache: true
plan: BASE
consumption: true
consumption_detail: true
consumption_max_power: true
consumption_price_hc: 0
consumption_price_hp: 0
consumption_price_base: 0
consumption_max_date: ''
consumption_detail_max_date: ''
production: false
production_detail: false
production_max_date: ''
production_detail_max_date: ''
production_price: 0
offpeak_hours_0: ''
offpeak_hours_1: ''
offpeak_hours_2: ''
offpeak_hours_3: ''
offpeak_hours_4: ''
offpeak_hours_5: ''
offpeak_hours_6: ''
refresh_addresse: false
refresh_contract: false
opentelemetry:
enable: false
service_name: myelectricaldata
endpoint: http://localhost:4317
environment: production
extension:
- fastapi
- sqlalchemy
server: # Configuration du serveur web.
cidr: 0.0.0.0
port: 5000
certfile: ''
keyfile: ''
cycle: 14400
117 changes: 0 additions & 117 deletions config.exemple.yaml

This file was deleted.

Loading

0 comments on commit 299af44

Please sign in to comment.