-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Develop db_sync dockerfile and add input to build docker image on wor…
…flow
- Loading branch information
Showing
7 changed files
with
117 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
FROM python:3.11-alpine3.17 | ||
WORKDIR /db_sync | ||
RUN python -m pip install --upgrade pip | ||
ADD ./ ./ | ||
RUN apk add build-base | ||
RUN pip install -r ./code/cycler/requirements.txt | ||
CMD ["python", "./code/cycler/src/wattrex_battery_cycler/mid/mid_sync/db_sync.py"] | ||
FROM python:3.10-bullseye as db_sync_base | ||
ARG USER=default | ||
ARG GROUP=default | ||
ENV U_ID=${USER} | ||
ENV G_UID=${GROUP} | ||
ENV UG_NAME=wattrex | ||
RUN addgroup --system --gid ${G_UID} ${UG_NAME} && adduser --system --gid ${G_UID} --uid ${U_ID} ${UG_NAME} | ||
USER ${UG_NAME} | ||
ENV APP_PATH=/cycler | ||
WORKDIR ${APP_PATH} | ||
ENV PATH="${PATH}:/home/${UG_NAME}/.local/bin" | ||
RUN pip install --upgrade pip | ||
ADD --chown=${UG_NAME}:${UG_NAME} ./devops/config_params_example.yaml ./devops/config_params.yaml | ||
ENV CONFIG_FILE_PATH=${APP_PATH}/devops/config_params.yaml | ||
ADD --chown=${UG_NAME}:${UG_NAME} ./devops/db_sync ./devops/db_sync | ||
|
||
FROM db_sync_base as db_sync_local | ||
ARG UPDATE_REQS=default | ||
ADD --chown=${UG_NAME}:${UG_NAME} ./code/db_sync ./code/db_sync | ||
RUN pip install -r ./code/db_sync/requirements.txt | ||
CMD ["python", "./devops/db_sync/run_db_sync.py"] | ||
|
||
FROM db_sync_base as db_sync_prod | ||
ARG UPDATE_REQS=default | ||
RUN pip install wattrex-cycler-db-sync | ||
CMD ["python", "./devops/db_sync/run_db_sync.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/python3 | ||
""" | ||
DB SYNC | ||
""" | ||
####################### MANDATORY IMPORTS ####################### | ||
|
||
####################### GENERIC IMPORTS ####################### | ||
import os | ||
import sys | ||
import threading | ||
|
||
####################### THIRD PARTY IMPORTS ####################### | ||
|
||
####################### SYSTEM ABSTRACTION IMPORTS ####################### | ||
from system_logger_tool import sys_log_logger_get_module_logger, SysLogLoggerC, Logger | ||
|
||
####################### LOGGER CONFIGURATION ####################### | ||
cycler_logger = SysLogLoggerC(file_log_levels='./devops/db_sync/log_config.yaml', | ||
output_sub_folder='db_sync') | ||
log: Logger = sys_log_logger_get_module_logger(__name__) | ||
|
||
####################### MODULE IMPORTS ####################### | ||
sys.path.append(os.path.dirname(__file__)+'/../') | ||
#from code.db_sync.src.wattrex_cycler_db_sync import DbSyncNodeC | ||
from wattrex_cycler_db_sync import DbSyncNodeC | ||
|
||
####################### PROJECT IMPORTS ####################### | ||
|
||
####################### ENUMS ####################### | ||
|
||
####################### CLASSES ####################### | ||
|
||
####################### FUNCTIONS ####################### | ||
|
||
if __name__ == '__main__': | ||
working_flag_event : threading.Event = threading.Event() | ||
working_flag_event.set() | ||
db_sync_node = DbSyncNodeC(working_flag=working_flag_event) | ||
db_sync_node.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters