Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docker-launcher/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Python
__pycache__/
*.py[cod]
*.so
.Python
venv/
.venv/

# PyInstaller
build/
dist/
*.spec.bak

# IDE
.idea/
.vscode/
*.swp

# OS
.DS_Store
Thumbs.db

# Docker
*.log

# Temp
*.tmp
*.bak

164 changes: 164 additions & 0 deletions docker-launcher/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# eSim Docker Container
# Multi-stage build to keep the image smaller (~3.5GB vs ~5GB)
# FOSSEE IIT Bombay

# ============================================
# Stage 1: Build dependencies
# ============================================
FROM ubuntu:22.04 AS builder

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Kolkata

# Install build tools
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential gcc g++ make cmake git \
python3 python3-pip python3-dev python3-venv \
autoconf automake libtool pkg-config bison flex gettext wget \
libgtk-3-dev \
&& rm -rf /var/lib/apt/lists/*

# Clone eSim
RUN git clone --depth 1 https://github.com/FOSSEE/eSim.git /build/esim

# Setup Python venv with dependencies
# Note: setuptools<58 is needed for hdlparse which uses deprecated use_2to3
RUN python3 -m venv /build/venv \
&& /build/venv/bin/pip install --no-cache-dir "setuptools<58.0.0" wheel \
&& /build/venv/bin/pip install --no-cache-dir \
matplotlib==3.7.5 numpy==1.24.4 scipy==1.10.1 \
PyQt5==5.15.7 pillow==10.4.0 hdlparse==1.0.4 watchdog==4.0.2

# Build GAW3 (analog waveform viewer) from source
# gtkwave is digital only, gaw3 is what eSim actually uses
RUN git clone --depth 1 https://github.com/StefanSchippers/xschem-gaw.git /build/gaw3 \
&& cd /build/gaw3 \
&& aclocal && autoheader \
&& automake --add-missing --foreign 2>/dev/null || true \
&& autoconf \
&& sed -i 's/GETTEXT_MACRO_VERSION = 0.18/GETTEXT_MACRO_VERSION = 0.20/' po/Makefile.in.in \
&& ./configure --prefix=/usr/local \
&& make -j$(nproc) \
&& make DESTDIR=/build/gaw3-install install


# ============================================
# Stage 2: Runtime image
# ============================================
FROM ubuntu:22.04

LABEL maintainer="FOSSEE IIT Bombay"
LABEL description="eSim EDA Tool with GUI support"

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Kolkata
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8

# eSim paths
ENV ESIM_HOME=/usr/local/esim
ENV PYTHONPATH="${ESIM_HOME}/src:/opt/venv/lib/python3.10/site-packages"

# VNC settings
ENV VNC_PORT=5901
ENV NOVNC_PORT=6080
ENV VNC_RESOLUTION=1920x1080
ENV VNC_DEPTH=24

# Desktop and font rendering settings
ENV GTK_THEME=Adwaita
ENV UBUNTU_MENUPROXY=0
ENV XDG_DATA_DIRS=/usr/share:/usr/local/share:/usr/share/icons
ENV QT_AUTO_SCREEN_SCALE_FACTOR=1
ENV GDK_SCALE=1
ENV FREETYPE_PROPERTIES="truetype:interpreter-version=40"

# Install runtime packages
RUN apt-get update && apt-get install -y --no-install-recommends \
kicad kicad-libraries ngspice gtkwave xterm \
python3 python3-wxgtk4.0 \
libx11-6 libxext6 libxrender1 libxfixes3 libxi6 libxrandr2 \
libxcursor1 libxinerama1 libgl1 libgl1-mesa-glx libgl1-mesa-dri \
libxcb1 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 \
libxcb-render-util0 libxcb-shape0 libxcb-xfixes0 libxcb-xinerama0 \
libxcb-xkb1 libxkbcommon0 libxkbcommon-x11-0 dbus-x11 \
adwaita-icon-theme-full hicolor-icon-theme gnome-icon-theme \
oxygen-icon-theme tango-icon-theme humanity-icon-theme \
ca-certificates libgtk-3-0 libcanberra-gtk-module xdg-utils \
libglib2.0-0 libfontconfig1 libfreetype6 \
tigervnc-standalone-server tigervnc-common \
xfce4 xfce4-terminal novnc websockify \
xdotool wmctrl openbox tint2 \
&& rm -rf /var/lib/apt/lists/* && apt-get clean

# Copy built artifacts from builder stage
COPY --from=builder /build/gaw3-install/usr/local /usr/local/
COPY --from=builder /build/esim ${ESIM_HOME}
COPY --from=builder /build/venv /opt/venv

# Create user
ARG USERNAME=esim-user
ARG USER_UID=1000
ARG USER_GID=1000

RUN groupadd --gid ${USER_GID} ${USERNAME} \
&& useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} \
&& mkdir -p /home/${USERNAME}/workspace \
&& chown -R ${USERNAME}:${USERNAME} /home/${USERNAME} \
&& chown -R ${USERNAME}:${USERNAME} ${ESIM_HOME}

WORKDIR ${ESIM_HOME}/src/frontEnd

# Create eSim config
RUN mkdir -p /home/${USERNAME}/.esim \
&& printf '[DEFAULT]\nworkspace=/home/%s/eSim-Workspace\n\n[eSim]\nworkspace=/home/%s/eSim-Workspace\nkicad=/usr/bin\nngspice=/usr/bin\n' \
${USERNAME} ${USERNAME} > /home/${USERNAME}/.esim/config.ini \
&& echo '{}' > /home/${USERNAME}/.esim/modelica_map.json \
&& chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.esim

# Setup KiCad symbol libraries
RUN mkdir -p /home/${USERNAME}/.config/kicad/6.0 \
&& KICAD_CONFIG=/home/${USERNAME}/.config/kicad/6.0 \
&& ESIM_SYMLIB=/usr/local/esim/library/kicadLibrary/eSim-symbols \
&& KICAD_SYMLIB=/usr/share/kicad/symbols \
&& echo '(sym_lib_table' > ${KICAD_CONFIG}/sym-lib-table \
&& for lib in eSim_Devices eSim_Sources eSim_Analog eSim_Digital eSim_Hybrid eSim_Power eSim_Subckt eSim_Miscellaneous eSim_Plot eSim_Nghdl eSim_Ngveri eSim_SKY130 eSim_SKY130_Subckts eSim_User; do \
echo " (lib (name \"$lib\")(type \"KiCad\")(uri \"${ESIM_SYMLIB}/${lib}.kicad_sym\")(options \"\")(descr \"\"))" >> ${KICAD_CONFIG}/sym-lib-table; \
done \
&& for lib in Device power Simulation_SPICE Connector Analog Transistor_BJT Transistor_FET Diode Amplifier_Operational; do \
echo " (lib (name \"$lib\")(type \"KiCad\")(uri \"${KICAD_SYMLIB}/${lib}.kicad_sym\")(options \"\")(descr \"\"))" >> ${KICAD_CONFIG}/sym-lib-table; \
done \
&& echo ')' >> ${KICAD_CONFIG}/sym-lib-table \
&& echo '(fp_lib_table)' > ${KICAD_CONFIG}/fp-lib-table \
&& chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.config

# Setup VNC with openbox + tint2 taskbar
RUN mkdir -p /home/${USERNAME}/.vnc \
&& printf '#!/bin/bash\nunset SESSION_MANAGER\nunset DBUS_SESSION_BUS_ADDRESS\nexport XDG_RUNTIME_DIR=/tmp/runtime-esim-user\nmkdir -p $XDG_RUNTIME_DIR && chmod 700 $XDG_RUNTIME_DIR\ntint2 &\nexec openbox-session\n' \
> /home/${USERNAME}/.vnc/xstartup \
&& chmod +x /home/${USERNAME}/.vnc/xstartup \
&& printf '\x9f\x87\x18\xb4\x8e\x8f\x8a\x57' > /home/${USERNAME}/.vnc/passwd \
&& chmod 600 /home/${USERNAME}/.vnc/passwd \
&& chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.vnc

# XFCE config to fix window focus issues
RUN mkdir -p /home/${USERNAME}/.config/xfce4/xfconf/xfce-perchannel-xml \
&& printf '<?xml version="1.0" encoding="UTF-8"?>\n<channel name="xfwm4" version="1.0">\n <property name="general" type="empty">\n <property name="focus_new" type="bool" value="true"/>\n <property name="raise_on_focus" type="bool" value="true"/>\n <property name="prevent_focus_stealing" type="bool" value="false"/>\n </property>\n</channel>\n' \
> /home/${USERNAME}/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml \
&& chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.config

# Font rendering config for better VNC quality
RUN mkdir -p /home/${USERNAME}/.config/fontconfig \
&& printf '<?xml version="1.0"?>\n<!DOCTYPE fontconfig SYSTEM "fonts.dtd">\n<fontconfig>\n <match target="font"><edit name="antialias" mode="assign"><bool>true</bool></edit></match>\n <match target="font"><edit name="hinting" mode="assign"><bool>true</bool></edit></match>\n <match target="font"><edit name="hintstyle" mode="assign"><const>hintslight</const></edit></match>\n <match target="font"><edit name="rgba" mode="assign"><const>rgb</const></edit></match>\n</fontconfig>\n' \
> /home/${USERNAME}/.config/fontconfig/fonts.conf \
&& chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.config/fontconfig

# Startup script
RUN printf '#!/bin/bash\nset -e\n\n# Ensure workspace exists\nmkdir -p /home/esim-user/eSim-Workspace\ncp -rn /usr/local/esim/Examples/* /home/esim-user/eSim-Workspace/ 2>/dev/null || true\n\nif [ "$1" = "--vnc" ] || [ "$USE_VNC" = "1" ]; then\n echo "Starting eSim in VNC mode"\n vncserver -kill :1 2>/dev/null || true\n export XDG_RUNTIME_DIR=/tmp/runtime-esim-user\n mkdir -p $XDG_RUNTIME_DIR && chmod 700 $XDG_RUNTIME_DIR\n vncserver :1 -geometry ${VNC_RESOLUTION:-1920x1080} -depth ${VNC_DEPTH:-24} -SecurityTypes None\n sleep 3\n websockify --web=/usr/share/novnc/ ${NOVNC_PORT:-6080} localhost:5901 &\n echo "VNC ready at http://localhost:${NOVNC_PORT:-6080}/vnc.html"\n export DISPLAY=:1\n sleep 2\n cd /usr/local/esim/src/frontEnd\n python3 Application.py\n tail -f /dev/null\nelse\n echo "Starting eSim in X11 mode"\n cd /usr/local/esim/src/frontEnd\n exec python3 Application.py\nfi\n' \
> /usr/local/bin/start-esim.sh \
&& chmod +x /usr/local/bin/start-esim.sh

USER ${USERNAME}

ENTRYPOINT ["/usr/local/bin/start-esim.sh"]
CMD []
154 changes: 154 additions & 0 deletions docker-launcher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# eSim Docker

<p align="center">
<img src="assets/esim_logo.png" alt="eSim Logo" width="80"/>
<img src="assets/esim_text.png" alt="eSim" width="200"/>
</p>

<p align="center">
<b>Run eSim anywhere using Docker - No installation required!</b>
</p>

<p align="center">
<a href="../../releases/latest">Download Launcher</a> •
<a href="#quick-start">Quick Start</a> •
<a href="#troubleshooting">Troubleshooting</a>
</p>

---

## About

This project provides a Docker-based solution to run **eSim** (Electronic Circuit Simulation) on any operating system. eSim is developed by FOSSEE, IIT Bombay and integrates KiCad, Ngspice, and Python for circuit design and simulation.

**What's included:**
- KiCad for schematic design
- Ngspice for SPICE simulation
- GAW3 analog waveform viewer
- All eSim libraries pre-configured

---

## Quick Start

### Step 1: Get Docker

Download [Docker Desktop](https://www.docker.com/products/docker-desktop) and make sure it's running.

### Step 2: Download the Launcher

Go to [Releases](../../releases/latest) and download:
- Windows: `eSim-Launcher-Windows.exe`
- Linux: `eSim-Launcher-Linux`
- macOS: `eSim-Launcher-macOS`

### Step 3: Run it

**Windows:** Double-click the `.exe` file.

**Linux:** Open terminal and run:
```bash
chmod +x eSim-Launcher-Linux
./eSim-Launcher-Linux
```

**macOS:** Open terminal and run:
```bash
chmod +x eSim-Launcher-macOS
./eSim-Launcher-macOS
```

---

## Display Modes

The launcher offers two display modes:

| Mode | Best For | How it Works |
|------|----------|--------------|
| **VNC** | Windows, macOS | Opens eSim in your browser. Works everywhere, no setup needed. |
| **X11** | Linux | Opens eSim in a native window. Best performance on Linux. |

### Recommendations

- **Linux** → Use X11 mode (recommended, no lag)
- **Windows** → Use VNC mode (X11 works but KiCad may lag)
- **macOS** → Use VNC mode (X11 requires XQuartz)

Both modes work on all platforms - the launcher will guide you through any required setup.

---

## Command Line Usage

```bash
# Interactive menu
python run_esim_docker.py

# Direct VNC mode
python run_esim_docker.py --vnc

# Direct X11 mode
python run_esim_docker.py --x11

# Update image
python run_esim_docker.py --pull
```

---

## Workspace

Your projects are saved to:

| OS | Location |
|----|----------|
| Windows | `C:\Users\<you>\eSim_Workspace` |
| Linux/macOS | `~/eSim_Workspace` |

This folder is mounted into the container, so your files persist.

---

## Troubleshooting

### Docker not running
Open Docker Desktop and wait for it to fully start.

### Browser shows "localhost not found"
Wait a few seconds and refresh. The container needs time to start.

### VNC shows blank screen
Refresh the browser page. If still blank, restart the launcher.

### X11 mode: window doesn't appear (Windows)
Make sure VcXsrv is running. The launcher auto-installs it if needed.

### X11 mode: window doesn't appear (macOS)
Install XQuartz from xquartz.org, then run `xhost +localhost` in terminal.

---

## Building from Source

```bash
docker build -t esim:latest .
python run_esim_docker.py --build
```

---

## Credits

- **eSim** - FOSSEE Team, IIT Bombay
- **KiCad** - KiCad Developers
- **Ngspice** - Ngspice Team
- **GAW3** - Hervé Quillévéré, Stefan Schippers

Created as part of the FOSSEE Internship program.

---

## License

GPL-3.0
Binary file added docker-launcher/assets/esim_logo.icns
Binary file not shown.
Binary file added docker-launcher/assets/esim_logo.ico
Binary file not shown.
Binary file added docker-launcher/assets/esim_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docker-launcher/assets/esim_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions docker-launcher/eSim.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# PyInstaller spec file for eSim Docker Launcher
# Build: pyinstaller eSim.spec

block_cipher = None

a = Analysis(
['run_esim_docker.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=['socket', 'webbrowser', 'threading', 'tempfile', 'argparse'],
hookspath=[],
runtime_hooks=[],
excludes=['tkinter', 'matplotlib', 'numpy', 'scipy', 'PIL', 'pandas', 'pytest'],
cipher=block_cipher,
)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='eSim-Launcher',
debug=False,
strip=False,
upx=True,
console=True, # Keep console for menu
icon='esim_logo.png' if __import__('os').path.exists('esim_logo.png') else None,
)
Loading