Skip to content

Commit

Permalink
Fix staging
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuMoalic committed Mar 22, 2024
1 parent ed36d6f commit 48fb1f5
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 104 deletions.
15 changes: 5 additions & 10 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
SECRET_KEY=
NODE_ID=0
NODE_NAME=""
# MANAGER_URL="localhost:8000"
MANAGER_URL=manager:8000
TOKEN=
SMB_USER=amuman
SMB_PASSWORD=
SMB_URL=//..../
SMB_MOUNT_POINT=/nas
DOMAIN=example.com
SECRET_KEY=random_string
DJANGO_SUPERUSER_EMAIL=[email protected]
DJANGO_SUPERUSER_USERNAME=admin
DJANGO_SUPERUSER_PASSWORD=random_string
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
ghcr.io/${{ github.repository }}/frontend
tags: |
type=ref,event=pr
type=semver,pattern={{version}}
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Build and push image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: .
context: ./frontend
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
27 changes: 0 additions & 27 deletions flake.lock

This file was deleted.

27 changes: 0 additions & 27 deletions flake.nix

This file was deleted.

19 changes: 13 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set dotenv-load

proxy:
podman run -d --replace --tz local --pull newer \
podman run --rm -it --replace --tz local --pull newer \
--name amuman-proxy-staging \
--network amuman-staging \
-v ./proxy/nginx.conf:/etc/nginx/conf.d/default.conf:z \
Expand All @@ -10,21 +10,21 @@ proxy:
frontend:
podman build ./frontend -t amuman-frontend-staging

podman run -d --replace --tz local --pull newer \
podman run --rm -it --replace --tz local --pull newer \
--name amuman-frontend-staging \
--network amuman-staging \
amuman-frontend-staging

redis:
podman run -d --replace --tz local --pull newer \
podman run --rm -it --replace --tz local --pull newer \
--name amuman-redis-staging \
--network amuman-staging \
docker.io/redis:7.2.4-alpine3.19

manager:
podman build ./manager -t amuman-manager-staging

podman run -d --replace --tz local --pull newer \
podman run --rm -it --replace --tz local --pull newer \
--name amuman-manager-staging \
--network amuman-staging \
-v ./staging:/manager \
Expand All @@ -33,18 +33,25 @@ manager:
-e DJANGO_SUPERUSER_USERNAME=$DJANGO_SUPERUSER_USERNAME \
-e DJANGO_SUPERUSER_PASSWORD=$DJANGO_SUPERUSER_PASSWORD \
-e DOMAIN=$DOMAIN \
-e REDIS_HOST=amuman-redis-staging \
amuman-manager-staging

node:
podman build ./node -t amuman-node-staging

podman run --rm -it --replace --tz local --pull newer \
--name amuman-node-staging \
--network amuman-staging \
--device=nvidia.com/gpu=all \
-v ./mock_nas:/mnt/smb \
-e MANAGER_DOMAIN=$DOMAIN \
-e NODE_NAME=staging-node-1 \
amuman-node-staging

staging: frontend redis manager proxy
staging: frontend redis manager proxy

kill-staging:
podman rm -f amuman-proxy-staging
podman rm -f amuman-frontend-staging
podman rm -f amuman-redis-staging
podman rm -f amuman-manager-staging
podman rm -f amuman-node-staging
8 changes: 1 addition & 7 deletions manager/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ COPY . .

RUN mkdir -p /manager

ENV SECRET_KEY=
ENV DJANGO_SUPERUSER_EMAIL=
ENV DJANGO_SUPERUSER_USERNAME=
ENV DJANGO_SUPERUSER_PASSWORD=
ENV DOMAIN_URL=
ENV DEBUG=FALSE
ENV REDIS_URL="amuman-redis-staging:6379"

ENTRYPOINT ["/app/staging.entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]
File renamed without changes.
2 changes: 1 addition & 1 deletion node/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ COPY . .
RUN pip install .
ENV SMB_MOUNT_POINT=/mnt/smb

ENTRYPOINT ["/app/staging.entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]
12 changes: 8 additions & 4 deletions node/amuman_node/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ def __init__(self) -> None:
self.manager_domain: str = os.getenv("MANAGER_DOMAIN", "localhost:8000")
self.node_id: int = int(os.getenv("NODE_ID", 0))
self.node_name: str = os.getenv("NODE_NAME", str(uuid.uuid1()))
self.node_user: str = os.getenv("NODE_USER", "admin")
self.node_password: str = os.getenv("NODE_PASSWORD", "admin")
log.debug(
f"Manager URL: '{self.manager_domain}', Node ID: {self.node_id}, Node Name: '{self.node_name}'"
f"Manager domain: '{self.manager_domain}', Node ID: {self.node_id}, Node Name: '{self.node_name}'"
)
self.reconnect_attempts: int = 10
self.reconnect_delay: int = 10
Expand All @@ -66,12 +68,14 @@ async def start(self) -> None:
await asyncio.sleep(self.sleep_time)

def authenticate(self) -> bool:
print(f"https://{self.manager_domain}/api/token/")
print(self.node_user, self.node_password)
try:
response = requests.post(
f"http://{self.manager_domain}/api/token/",
f"https://{self.manager_domain}/api/token/",
json={
"username": os.getenv("NODE_USER", "admin"),
"password": os.getenv("NODE_PASSWORD", "admin"),
"username": self.node_user,
"password": self.node_password,
},
)
log.debug(
Expand Down
File renamed without changes.
12 changes: 0 additions & 12 deletions node/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,3 @@ dev cmd="bash":
-e NODE_NAME=test_node \
--env-file ../.env \
amuman-node-dev {{cmd}}

staging:
podman network create --ignore amuman-staging
podman build . -t amuman-node-staging
podman run --rm -it --replace --tz local --pull newer \
--name amuman-node-staging \
--network amuman-dev \
-v ./..:/app \
-v ./../mock_nas:/mnt/smb \
-w /app/node \
--device=nvidia.com/gpu=all \
amuman-node-staging
10 changes: 4 additions & 6 deletions proxy/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
server {
client_max_body_size 1G;

listen 80;

server_name localhost;

location /api/ {
proxy_pass http://amuman-manager-staging:8000;
proxy_pass http://amuman-manager:8000;
}
location /admin/ {
proxy_pass http://amuman-manager-staging:8000;
proxy_pass http://amuman-manager:8000;
}
location /static/ {
proxy_pass http://amuman-manager-staging:8000;
proxy_pass http://amuman-manager:8000;
}

location / {
proxy_pass http://amuman-frontend-staging:3000/;
proxy_pass http://amuman-frontend:3000/;
}
}

0 comments on commit 48fb1f5

Please sign in to comment.