Skip to content

Commit

Permalink
feat: update build esp script and add dockerfile/compose
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto-abarzua committed Nov 8, 2023
1 parent 0ac49d9 commit 92aa3ba
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 36 deletions.
7 changes: 5 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ FROM python:3.11-slim-buster

WORKDIR /app

RUN apt-get update && apt-get install -y build-essential
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential && \
rm -rf /var/lib/apt/lists/*

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

ENV PYTHONPATH=/app/src


RUN pip install pdm==2.10
RUN pip install --no-cache-dir pdm==2.10

COPY ./pyproject.toml ./pyproject.toml
COPY ./pdm.lock ./pdm.lock
Expand Down
2 changes: 1 addition & 1 deletion controller/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN pip install pdm==2.10
RUN pip install --no-cache-dir pdm==2.10

ENV PYTHONPATH "${PYTHONPATH}:/app/src"

Expand Down
16 changes: 16 additions & 0 deletions docker_services/esp_idf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.8'
services:
esp_idf:
build:
context: ../firmware
dockerfile: Dockerfile.espidf
volumes:
- ../firmware/main:/app/main
- ../firmware/CMakeLists.txt:/app/CMakeLists.txt
- ../firmware/components:/app/components
environment:
- ESP_WIFI_SSID
- ESP_WIFI_PASSWORD
- ESP_CONTROLLER_SERVER_HOST
- ESP_CONTROLLER_SERVER_PORT
- VERBOSE
65 changes: 65 additions & 0 deletions firmware/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# General
*.git
*.gitignore
*.dockerignore
*.md
*.pdf
*.gz
*.zip

# Specific to C/C++/CMake
*.o
*.a
*.lo
*.la
*.so
*.so.*
*.dylib
*.lib
*.dll
*.exe
*.out
*.app
CMakeCache.txt
CMakeFiles
cmake-build-*
build
Debug
Release
*.log
*.tlog
*.idb
*.pdb
*.opendb
*.ilk
*.deps
*.suo
*.user
*.user.*
*.aps
*.ncb
*.sdf
*.VC.db
*.VC.VC.opendb
.vs
.DS_Store

# ESP-IDF specific
build/
flash_project_args.json
partition_table/
*.elf
*.bin
*.map

# Dependency directories (uncomment if not needed)
# components/
# build/

# Python
**/__pycache__
**/*.pyc
**/*.pyo
**/*.pyd
.Python

9 changes: 5 additions & 4 deletions firmware/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM debian:latest
FROM ubuntu:jammy

RUN apt-get update && apt-get install -y \
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
make \
clang \
Expand All @@ -15,9 +16,9 @@ RUN apt-get update && apt-get install -y \
WORKDIR /app
COPY . .

RUN chmod +x /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh && \
rm -rf CMakeCache.txt CMakeFiles cmake_install.cmake Makefile

RUN rm -rf CMakeCache.txt CMakeFiles cmake_install.cmake Makefile

ENTRYPOINT ["/app/entrypoint.sh"]

Expand Down
7 changes: 7 additions & 0 deletions firmware/Dockerfile.espidf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM espressif/idf:release-v5.0

WORKDIR /app

COPY . .

CMD ["idf.py", "build"]
Binary file added firmware/app
Binary file not shown.
3 changes: 2 additions & 1 deletion firmware/components/movement/endstops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ void HallEffectSensor::hardware_setup() {}

bool HallEffectSensor::hardware_read_state() { return true; }

#endif

NoneEndStop::NoneEndStop() : EndStop(-1) {}

NoneEndStop::~NoneEndStop() {}

void NoneEndStop::hardware_setup() {}

bool NoneEndStop::hardware_read_state() { return true; }
#endif
8 changes: 4 additions & 4 deletions firmware/config.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef CONFIG_H
#define CONFIG_H

#define WIFI_SSID ""
#define WIFI_PASSWORD ""
#define CONTROLLER_SERVER_HOST ""
#define CONTROLLER_SERVER_PORT
#define WIFI_SSID "PALVI"
#define WIFI_PASSWORD "Palvi.1400"
#define CONTROLLER_SERVER_HOST "backend"
#define CONTROLLER_SERVER_PORT 8500

#endif // CONFIG_H
18 changes: 0 additions & 18 deletions firmware/entrypoint_esp.sh

This file was deleted.

1 change: 0 additions & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

FROM node:20

WORKDIR /app
Expand Down
13 changes: 8 additions & 5 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,20 @@ def down(**kwargs):

def build(**kwargs):
no_cache = kwargs['no_cache']
files = ['firmware.yaml', 'controller.yaml',
'backend.yaml', 'frontend.yaml', 'unity_webgl_server.yaml','esp_idf.yaml']
if no_cache:
dcb(['firmware.yaml', 'controller.yaml',
'backend.yaml', 'frontend.yaml'], no_cache=True)
dcb(files, no_cache=True)
else:
dcb(['firmware.yaml', 'controller.yaml', 'backend.yaml', 'frontend.yaml'])
dcb(files)


def build_esp(**kwargs):
os.environ['CONTROLLER_SERVER_HOST'] = get_ip()
os.environ['ESP_CONTROLLER_SERVER_HOST'] = get_ip()
os.environ['VERBOSE'] = '1'
source_env('.env')
subprocess.check_call(['./firmware/entrypoint_esp.sh'])
# subprocess.check_call(['./firmware/entrypoint_esp.sh'])
dcr('esp_idf.yaml', 'esp_idf')


def format_code(**kwargs):
Expand Down

0 comments on commit 92aa3ba

Please sign in to comment.