Skip to content

Commit 35b4552

Browse files
committed
better docker build
1 parent f70baba commit 35b4552

3 files changed

Lines changed: 38 additions & 12 deletions

File tree

.dockerignore

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,19 @@ Dockerfile
55
*.gif
66
*.png
77
docker
8-
docs
8+
docs
9+
node_modules
10+
build
11+
lib
12+
include
13+
__pycache__
14+
*.pyc
15+
*.pyo
16+
*.pyd
17+
.Python
18+
*.so
19+
*.egg-info
20+
.git
21+
.github
22+
.nox
23+
*.log

.github/workflows/docker-publish.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ jobs:
3131
context: ./
3232
file: ./Dockerfile
3333
push: true
34-
platforms: linux/amd64,linux/arm64
34+
platforms: linux/amd64
35+
cache-from: type=registry,ref=edryslabs/module-pyxtermjs:base-cache
36+
cache-to: type=registry,ref=edryslabs/module-pyxtermjs:base-cache,mode=max
3537
tags: |
3638
edryslabs/module-pyxtermjs:base
3739
edryslabs/module-pyxtermjs:base-${{ github.run_number }}
@@ -60,7 +62,9 @@ jobs:
6062
context: ./docker/arduino
6163
file: ./docker/arduino/Dockerfile
6264
push: true
63-
platforms: linux/amd64,linux/arm64
65+
platforms: linux/amd64
66+
cache-from: type=registry,ref=edryslabs/module-pyxtermjs:arduino-cache
67+
cache-to: type=registry,ref=edryslabs/module-pyxtermjs:arduino-cache,mode=max
6468
tags: |
6569
edryslabs/module-pyxtermjs:arduino-v${{ github.run_number }}
6670
edryslabs/module-pyxtermjs:latest
@@ -89,7 +93,9 @@ jobs:
8993
context: ./docker/development
9094
file: ./docker/development/Dockerfile
9195
push: true
92-
platforms: linux/amd64,linux/arm64
96+
platforms: linux/amd64
97+
cache-from: type=registry,ref=edryslabs/module-pyxtermjs:development-cache
98+
cache-to: type=registry,ref=edryslabs/module-pyxtermjs:development-cache,mode=max
9399
tags: |
94100
edryslabs/module-pyxtermjs:development-v${{ github.run_number }}
95101
edryslabs/module-pyxtermjs:development

Dockerfile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
FROM ubuntu:22.04
22

3-
RUN apt-get update --fix-missing
4-
RUN apt-get install -y \
3+
# Install system dependencies
4+
RUN apt-get update --fix-missing && \
5+
apt-get install -y \
56
apt-utils \
67
python3 \
78
python3-pip \
89
vim \
910
htop \
10-
zsh
11+
zsh && \
12+
rm -rf /var/lib/apt/lists/*
1113

12-
COPY . /var/www
1314
WORKDIR "/var/www"
14-
15+
COPY requirements.txt .
1516
RUN pip3 install -r requirements.txt
1617

17-
# Setup appuser and appgroup
18+
# Setup appuser and appgroup before copying files
1819
ARG user=appuser
1920
ARG group=appuser
2021
ARG uid=1000
2122
ARG gid=1000
22-
RUN groupadd -g ${gid} ${group}
23-
RUN useradd -u ${uid} -g ${group} -s /bin/sh -m ${user} # <--- the '-m' create a user home directory
23+
RUN groupadd -g ${gid} ${group} && \
24+
useradd -u ${uid} -g ${group} -s /bin/sh -m ${user}
2425

26+
# Copy zsh configuration
2527
COPY _assets/.zshrc /home/appuser/.zshrc
2628
COPY _assets/oh-my-zsh /home/appuser/.oh-my-zsh
2729

30+
# Copy application files
31+
COPY . .
32+
2833
# Switch to user we must not set group to make the configuration done above apply
2934
# !! if ${user} is not setup correctly the next line might result in group being root !!
3035
USER ${user}

0 commit comments

Comments
 (0)