Skip to content

Commit d746615

Browse files
committed
chore(build): add multi-stage build with dev target
Introduces separate Docker stages for development workflow: - base: minimal system setup (apt sources, sudo, make) - dev: build dependencies installed, no project build - runtime: full build (original behavior) The dev target supports volume mounting for iterative development. Signed-off-by: Laudin Molina Troconis <laudin.molinatroconis@silabs.com>
1 parent 69d6e93 commit d746615

2 files changed

Lines changed: 32 additions & 12 deletions

File tree

Dockerfile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/echo run with: docker build . -f
22
# -*- coding: utf-8 -*-
33

4-
FROM arm32v7/debian:stretch
5-
ENV target_debian_arch armhf
4+
FROM arm32v7/debian:stretch AS base
5+
ENV target_debian_arch=armhf
66

7-
LABEL maintainer="Philippe Coval <philippe.coval@silabs.com>"
7+
LABEL maintainer="Laudin Molina Troconis <laudin.molinatroconis@silabs.com>"
88

9-
ENV DEBIAN_FRONTEND noninteractive
9+
ENV DEBIAN_FRONTEND=noninteractive
1010

1111
RUN echo "# log: Setup system" \
1212
&& set -x \
@@ -16,17 +16,20 @@ RUN echo "# log: Setup system" \
1616
&& apt-get install -y sudo make \
1717
&& date -u
1818

19-
ENV project zipgateway
20-
ENV workdir /usr/local/src/${project}
19+
FROM base AS dev
20+
ENV project=zipgateway
21+
ENV workdir=/usr/local/src/${project}
2122
WORKDIR ${workdir}
2223
COPY helper.mk ${workdir}
23-
RUN echo "# log: Install ${project}" \
24+
RUN echo "# log: Setup dependencies for ${project}" \
2425
&& set -x \
2526
&& ./helper.mk setup/debian/stretch \
27+
&& apt-get autoremove --purge \
28+
&& apt-get clean \
2629
&& date -u
2730

31+
FROM dev AS runtime
2832
COPY . ${workdir}
29-
WORKDIR ${workdir}
3033
RUN echo "# log: Build ${project}" \
3134
&& set -x \
3235
&& ./helper.mk \

docker-compose.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
# -*- coding: utf-8 -*-
22

3-
version: "2"
4-
53
services:
6-
default:
7-
build: .
4+
dev:
5+
image: zipgateway-dev
6+
build:
7+
context: .
8+
target: dev
9+
volumes:
10+
- .:/usr/local/src/zipgateway
11+
working_dir: /usr/local/src/zipgateway
12+
user: "${UID:-1000}:${GID:-1000}"
13+
stdin_open: true
14+
tty: true
15+
command: bash
16+
17+
runtime:
18+
build:
19+
context: .
20+
target: runtime
821
command: tests
922
devices:
1023
- /dev/ttyACM0:/dev/ttyACM0
24+
25+
# Alias for backward compatibility
26+
default:
27+
extends: runtime

0 commit comments

Comments
 (0)