Skip to content

Commit b8b29e1

Browse files
authored
Fix pushing docker images on manual workflow run (Gallopsled#2250)
* Fix pushing docker images on manual workflow run Running the docker workflow manually would associate the run with the `dev` branch. The generated tags would all point to the `dev` tag, so tag the image manually to the correct branch. * Fix building ci image It's called `python2.7` instead of `python`. * Add riscv64 binutils to base image
1 parent ff178aa commit b8b29e1

File tree

5 files changed

+59
-71
lines changed

5 files changed

+59
-71
lines changed

.github/workflows/docker.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ jobs:
1010
publish:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Docker meta
14-
id: meta
15-
uses: docker/metadata-action@v4
16-
with:
17-
images: |
18-
pwntools/pwntools
19-
tags: |
20-
type=ref,event=branch
21-
2213
# Required for subdirectories in Git context
2314
- name: Set up Docker Buildx
2415
uses: docker/setup-buildx-action@v2
@@ -43,26 +34,25 @@ jobs:
4334
with:
4435
context: "{{defaultContext}}:extra/docker/stable"
4536
push: true
46-
tags: ${{ steps.meta.outputs.tags }}
47-
labels: ${{ steps.meta.outputs.labels }}
37+
tags: pwntools/pwntools:stable
4838

4939
- name: Build and push beta image
5040
uses: docker/build-push-action@v4
5141
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/beta')
5242
with:
5343
context: "{{defaultContext}}:extra/docker/beta"
5444
push: true
55-
tags: ${{ steps.meta.outputs.tags }}
56-
labels: ${{ steps.meta.outputs.labels }}
45+
tags: pwntools/pwntools:beta
5746

5847
- name: Build and push dev image
5948
uses: docker/build-push-action@v4
6049
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/dev')
6150
with:
6251
context: "{{defaultContext}}:extra/docker/dev"
6352
push: true
64-
tags: ${{ steps.meta.outputs.tags }}
65-
labels: ${{ steps.meta.outputs.labels }}
53+
tags: |
54+
pwntools/pwntools:dev
55+
pwntools/pwntools:latest
6656
6757
- name: Build and push ci image
6858
uses: docker/build-push-action@v4
@@ -71,4 +61,3 @@ jobs:
7161
context: "{{defaultContext}}:travis/docker"
7262
push: true
7363
tags: pwntools/pwntools:ci
74-
labels: ${{ steps.meta.outputs.labels }}

extra/docker/base/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ RUN apt-get update \
2626
python3 \
2727
python3-pip \
2828
python3-dev \
29+
python-is-python3 \
2930
qemu-user-static \
3031
binutils-arm-linux-gnueabihf \
3132
binutils-aarch64-linux-gnu \
@@ -34,6 +35,7 @@ RUN apt-get update \
3435
binutils-powerpc-linux-gnu \
3536
binutils-powerpc64-linux-gnu \
3637
binutils-sparc64-linux-gnu \
38+
binutils-riscv64-linux-gnu \
3739
tmux \
3840
patchelf \
3941
&& locale-gen en_US.UTF-8 \

extra/docker/develop/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ RUN python2.7 -m pip install -U ipython ipdb \
3434
ARG DEBIAN_FRONTEND=noninteractive
3535
ENV TZ="UTC"
3636
RUN sudo apt-get update && sudo -E apt-get install -y \
37-
tzdata \
37+
tzdata \
3838
ash \
3939
bash \
4040
bash-static \

travis/docker/Dockerfile

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ENV HISTFILE=/home/pwntools/.history
55

66
# Uninstall existing versions of pwntools
77
USER root
8-
RUN python -m pip uninstall -q -y pwntools \
9-
&& python3 -m pip uninstall -q -y pwntools
8+
RUN python2.7 -m pip uninstall -q -y pwntools \
9+
&& python3 -m pip uninstall -q -y pwntools
1010

1111
# Switch back to the pwntools user from here forward
1212
USER pwntools
@@ -18,20 +18,23 @@ ENV PATH="/home/pwntools/.local/bin:${PATH}"
1818

1919
# Install Pwntools to the home directory, make it an editable install
2020
RUN git clone https://github.com/Gallopsled/pwntools \
21-
&& python -m pip install --upgrade --editable pwntools \
21+
&& python2.7 -m pip install --upgrade --editable pwntools \
2222
&& python3 -m pip install --upgrade --editable pwntools \
2323
&& PWNLIB_NOTERM=1 pwn version
2424

2525
# Requirements for running the tests
26-
RUN python -m pip install --upgrade --requirement pwntools/docs/requirements.txt \
27-
&& python3 -m pip install --upgrade --requirement pwntools/docs/requirements.txt
26+
RUN python2.7 -m pip install --upgrade --requirement pwntools/docs/requirements.txt \
27+
&& python3 -m pip install --upgrade --requirement pwntools/docs/requirements.txt
2828

2929
# Python niceties for debugging
30-
RUN python -m pip install -U ipython ipdb \
31-
&& python3 -m pip install -U ipython ipdb
30+
RUN python2.7 -m pip install -U ipython ipdb \
31+
&& python3 -m pip install -U ipython ipdb
3232

3333
# Dependencies from .travis.yml addons -> apt -> packages
34-
RUN sudo apt-get update && sudo apt-get install -y \
34+
ARG DEBIAN_FRONTEND=noninteractive
35+
ENV TZ="UTC"
36+
RUN sudo apt-get update && sudo -E apt-get install -y \
37+
tzdata \
3538
ash \
3639
bash \
3740
bash-static \
@@ -41,7 +44,7 @@ RUN sudo apt-get update && sudo apt-get install -y \
4144
dash \
4245
gcc \
4346
gcc-multilib \
44-
gdb \
47+
gdb \
4548
ksh \
4649
lib32stdc++6 \
4750
libc6-dev-i386 \
@@ -51,20 +54,17 @@ RUN sudo apt-get update && sudo apt-get install -y \
5154
socat \
5255
sshpass \
5356
vim \
54-
zsh
55-
57+
zsh \
5658
# Misc useful things when developing
57-
RUN sudo apt-get install -y \
5859
curl \
59-
ipython \
6060
ipython3 \
6161
lsb-release \
6262
ssh \
6363
unzip \
6464
wget
6565

6666
# Use zsh by default
67-
RUN sudo chsh -s /bin/zsh pwntools
67+
RUN sudo -E chsh -s /bin/zsh pwntools
6868

6969
# Get and install prezto
7070
RUN git clone --recursive https://github.com/sorin-ionescu/prezto.git .zprezto
@@ -84,24 +84,26 @@ ADD ipython_config.py /home/pwntools/.ipython/profile_default
8484

8585
# Do not require password for sudo
8686
RUN echo "pwntools ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/travis
87+
8788
# Some additional debugging tools that are useful
88-
RUN python -m pip install ipdb
89-
RUN python3 -m pip install ipdb
89+
RUN python2.7 -m pip install ipdb && \
90+
python3 -m pip install ipdb
9091

9192
# Install debugging utilities
9293
USER root
9394
RUN apt-get -y install gdb gdbserver tmux gdb-multiarch
9495

9596
# Set up binfmt-misc mappings inside the VM
9697
USER root
97-
RUN mkdir /etc/qemu-binfmt
98-
RUN ln -sf /usr/lib/arm-linux-gnueabihf /etc/qemu-binfmt/arm
99-
RUN ln -sf /usr/lib/aarch64-linux-gnu /etc/qemu-binfmt/aarch64
100-
RUN ln -sf /usr/lib/mips-linux-gnu /etc/qemu-binfmt/mips
101-
RUN ln -sf /usr/lib/mipsel-linux-gnu /etc/qemu-binfmt/mipsel
102-
RUN ln -sf /usr/lib/powerpc-linux-gnu /etc/qemu-binfmt/powerpc
103-
RUN ln -sf /usr/lib/powerpc-linux-gnu64 /etc/qemu-binfmt/powerpc64
104-
RUN ln -sf /usr/lib/sparc64-linux-gnu /etc/qemu-binfmt/sparc64
98+
RUN mkdir /etc/qemu-binfmt && \
99+
ln -sf /usr/lib/arm-linux-gnueabihf /etc/qemu-binfmt/arm && \
100+
ln -sf /usr/lib/aarch64-linux-gnu /etc/qemu-binfmt/aarch64 && \
101+
ln -sf /usr/lib/mips-linux-gnu /etc/qemu-binfmt/mips && \
102+
ln -sf /usr/lib/mipsel-linux-gnu /etc/qemu-binfmt/mipsel && \
103+
ln -sf /usr/lib/powerpc-linux-gnu /etc/qemu-binfmt/powerpc && \
104+
ln -sf /usr/lib/powerpc-linux-gnu64 /etc/qemu-binfmt/powerpc64 && \
105+
ln -sf /usr/lib/sparc64-linux-gnu /etc/qemu-binfmt/sparc64 && \
106+
ln -sf /usr/lib/riscv64-linux-gnu /etc/qemu-binfmt/riscv64
105107

106108
# Create the Travis user
107109
USER root
@@ -110,32 +112,29 @@ RUN echo "travis ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/travis
110112

111113
# Set up SSH stuff so we can SSH into localhost
112114
USER pwntools
113-
RUN ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ''
114-
RUN cp ~/.ssh/id_rsa.pub /tmp
115-
RUN echo \
115+
RUN ssh-keygen -t rsa -f ~/.ssh/id_rsa -N '' && \
116+
cp ~/.ssh/id_rsa.pub /tmp && \
117+
echo \
116118
"Host *\n\
117119
User travis\n\
118120
HostName 127.0.0.1\n\
119121
"> ~/.ssh/config
120122

121123
# Set up authorized_keys so we can login as travis with no creds
122124
USER travis
123-
RUN mkdir -m 0700 ~/.ssh
124-
RUN echo 'from="127.0.0.1"' $(cat /tmp/id_rsa.pub) > ~/.ssh/authorized_keys
125+
RUN mkdir -m 0700 ~/.ssh && \
126+
echo 'from="127.0.0.1"' $(cat /tmp/id_rsa.pub) > ~/.ssh/authorized_keys
125127

126128
# Add the doctest entrypoint to /usr/bin so we don't have to supply the full path
127129
USER root
128-
ADD doctest2 /usr/bin
129-
ADD doctest3 /usr/bin
130+
ADD doctest2 doctest3 /usr/bin
130131

131132
# Switch back to pwntools to actually run the image
132133
USER pwntools
133134
WORKDIR /home/pwntools
134135

135136
# Copy in the Doctest script
136-
COPY doctest2 /home/pwntools
137-
COPY doctest3 /home/pwntools
138-
COPY tmux.sh /home/pwntools
137+
COPY doctest2 doctest3 tmux.sh /home/pwntools
139138

140139
# Do everything in UTF-8 mode!
141140
ENV LANG=C.UTF-8

travis/docker/Dockerfile.travis

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11

22
# Some additional debugging tools that are useful
3-
RUN python -m pip install ipdb
4-
RUN python3 -m pip install ipdb
3+
RUN python2.7 -m pip install ipdb && \
4+
python3 -m pip install ipdb
55

66
# Install debugging utilities
77
USER root
88
RUN apt-get -y install gdb gdbserver tmux gdb-multiarch
99

1010
# Set up binfmt-misc mappings inside the VM
1111
USER root
12-
RUN mkdir /etc/qemu-binfmt
13-
RUN ln -sf /usr/lib/arm-linux-gnueabihf /etc/qemu-binfmt/arm
14-
RUN ln -sf /usr/lib/aarch64-linux-gnu /etc/qemu-binfmt/aarch64
15-
RUN ln -sf /usr/lib/mips-linux-gnu /etc/qemu-binfmt/mips
16-
RUN ln -sf /usr/lib/mipsel-linux-gnu /etc/qemu-binfmt/mipsel
17-
RUN ln -sf /usr/lib/powerpc-linux-gnu /etc/qemu-binfmt/powerpc
18-
RUN ln -sf /usr/lib/powerpc-linux-gnu64 /etc/qemu-binfmt/powerpc64
19-
RUN ln -sf /usr/lib/sparc64-linux-gnu /etc/qemu-binfmt/sparc64
12+
RUN mkdir /etc/qemu-binfmt && \
13+
ln -sf /usr/lib/arm-linux-gnueabihf /etc/qemu-binfmt/arm && \
14+
ln -sf /usr/lib/aarch64-linux-gnu /etc/qemu-binfmt/aarch64 && \
15+
ln -sf /usr/lib/mips-linux-gnu /etc/qemu-binfmt/mips && \
16+
ln -sf /usr/lib/mipsel-linux-gnu /etc/qemu-binfmt/mipsel && \
17+
ln -sf /usr/lib/powerpc-linux-gnu /etc/qemu-binfmt/powerpc && \
18+
ln -sf /usr/lib/powerpc-linux-gnu64 /etc/qemu-binfmt/powerpc64 && \
19+
ln -sf /usr/lib/sparc64-linux-gnu /etc/qemu-binfmt/sparc64 && \
20+
ln -sf /usr/lib/riscv64-linux-gnu /etc/qemu-binfmt/riscv64
2021

2122
# Create the Travis user
2223
USER root
@@ -25,32 +26,29 @@ RUN echo "travis ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/travis
2526

2627
# Set up SSH stuff so we can SSH into localhost
2728
USER pwntools
28-
RUN ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ''
29-
RUN cp ~/.ssh/id_rsa.pub /tmp
30-
RUN echo \
29+
RUN ssh-keygen -t rsa -f ~/.ssh/id_rsa -N '' && \
30+
cp ~/.ssh/id_rsa.pub /tmp && \
31+
echo \
3132
"Host *\n\
3233
User travis\n\
3334
HostName 127.0.0.1\n\
3435
"> ~/.ssh/config
3536

3637
# Set up authorized_keys so we can login as travis with no creds
3738
USER travis
38-
RUN mkdir -m 0700 ~/.ssh
39-
RUN echo 'from="127.0.0.1"' $(cat /tmp/id_rsa.pub) > ~/.ssh/authorized_keys
39+
RUN mkdir -m 0700 ~/.ssh && \
40+
echo 'from="127.0.0.1"' $(cat /tmp/id_rsa.pub) > ~/.ssh/authorized_keys
4041

4142
# Add the doctest entrypoint to /usr/bin so we don't have to supply the full path
4243
USER root
43-
ADD doctest2 /usr/bin
44-
ADD doctest3 /usr/bin
44+
ADD doctest2 doctest3 /usr/bin
4545

4646
# Switch back to pwntools to actually run the image
4747
USER pwntools
4848
WORKDIR /home/pwntools
4949

5050
# Copy in the Doctest script
51-
COPY doctest2 /home/pwntools
52-
COPY doctest3 /home/pwntools
53-
COPY tmux.sh /home/pwntools
51+
COPY doctest2 doctest3 tmux.sh /home/pwntools
5452

5553
# Do everything in UTF-8 mode!
5654
ENV LANG=C.UTF-8

0 commit comments

Comments
 (0)