Switch CMD to python loop. Make host an environment variable

This commit is contained in:
Luke Van Seters 2021-09-11 09:50:33 -06:00
parent 23d03b990d
commit b2d2c7dbeb
6 changed files with 15 additions and 7 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
tests
cache

View File

@ -18,4 +18,4 @@ COPY . /app
# easter eggs 😝 # easter eggs 😝
RUN echo "PS1='🕵️:\[\033[1;36m\]\h \[\033[1;34m\]\W\[\033[0;35m\]\[\033[1;36m\]$ \[\033[0m\]'" >> ~/.bashrc RUN echo "PS1='🕵️:\[\033[1;36m\]\h \[\033[1;34m\]\W\[\033[0;35m\]\[\033[1;36m\]$ \[\033[0m\]'" >> ~/.bashrc
CMD ["/bin/bash"] CMD [ "python", "run.py"]

View File

@ -11,7 +11,7 @@ k8s_yaml(secret_from_dict("mev-inspect-db-credentials", inputs = {
"password": "password", "password": "password",
})) }))
docker_build('mev-inspect', '.', docker_build('mev-inspect-py', '.',
live_update=[ live_update=[
sync('.', '/app'), sync('.', '/app'),
run('cd /app && poetry install', run('cd /app && poetry install',

View File

@ -16,9 +16,8 @@ spec:
spec: spec:
containers: containers:
- name: mev-inspect - name: mev-inspect
image: mev-inspect:latest image: mev-inspect-py
command: [ "/bin/bash", "-c", "--" ] command: [ "python", "run.py"]
args: [ "while true; do sleep 30; done;" ]
env: env:
- name: POSTGRES_USER - name: POSTGRES_USER
valueFrom: valueFrom:
@ -30,6 +29,8 @@ spec:
secretKeyRef: secretKeyRef:
name: mev-inspect-db-credentials name: mev-inspect-db-credentials
key: password key: password
- name: POSTGRES_HOST
value: postgresql
livenessProbe: livenessProbe:
exec: exec:
command: command:

View File

@ -7,9 +7,9 @@ from sqlalchemy.orm import sessionmaker
def get_sqlalchemy_database_uri(): def get_sqlalchemy_database_uri():
username = os.getenv("POSTGRES_USER") username = os.getenv("POSTGRES_USER")
password = os.getenv("POSTGRES_PASSWORD") password = os.getenv("POSTGRES_PASSWORD")
server = "postgresql" host = os.getenv("POSTGRES_HOST")
db_name = "mev_inspect" db_name = "mev_inspect"
return f"postgresql://{username}:{password}@{server}/{db_name}" return f"postgresql://{username}:{password}@{host}/{db_name}"
def get_engine(): def get_engine():

5
run.py Normal file
View File

@ -0,0 +1,5 @@
import time
if __name__ == "__main__":
while True:
time.sleep(30)