Skip to content

Commit 5f4c8e8

Browse files
Nisarg JhaveriNisarg Jhaveri
authored andcommitted
Run build as non-root user in docker
1 parent b538377 commit 5f4c8e8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ RUN apt-get -q -y install file wget cpio rsync locales \
1111
RUN apt-get -q -y autoremove && apt-get -q -y clean
1212
RUN update-locale LC_ALL=C
1313

14+
RUN useradd -ms /bin/bash buildroot
15+
16+
RUN mkdir -p /app/buildroot/dl && chown -R buildroot:buildroot /app/buildroot/dl
17+
RUN mkdir -p /app/buildroot/output && chown -R buildroot:buildroot /app/buildroot/output
18+
1419
VOLUME /app/buildroot/dl
1520
VOLUME /app/buildroot/output
1621

22+
USER buildroot
23+
1724
CMD /bin/bash

docker-compose.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.7'
2-
31
services:
42
bash: &base
53
build: .
@@ -10,11 +8,11 @@ services:
108
- output:/app/buildroot/output
119
working_dir: /app/buildroot
1210
command: bash
13-
11+
1412
generate_image_donotuse: &generate_image
1513
<<: *base
1614
command: bash -x -c "make BR2_EXTERNAL=../aa_wireless_dongle/ O=output/$${BOARD_NAME} $${BOARD_NAME}_defconfig && cd output/$${BOARD_NAME} && make && mkdir -p /app/images/ && cp images/sdcard.img /app/images/sdcard-$${BOARD_NAME}.img"
17-
15+
1816
rpi0w:
1917
<<: *generate_image
2018
environment:
@@ -24,7 +22,7 @@ services:
2422
<<: *generate_image
2523
environment:
2624
- BOARD_NAME=raspberrypizero2w
27-
25+
2826
rpi3a:
2927
<<: *generate_image
3028
environment:

0 commit comments

Comments
 (0)