Reputation: 421
Stackers,
I'm using Docker to containerize my app. In the stage below, I'm trying to pack it using UPX.
FROM alpine:3.8 AS compressor
# Version of upx to be used(without the 'v' prefix)
# For all releases, see https://github.com/upx/upx/releases
ARG UPX_VERSION=3.94
# Fetch upx, decompress it, make it executable.
ADD https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz /tmp/upx.tar.xy
RUN tar -xJOf /tmp/upx.tar.xy upx-${UPX_VERSION}-amd64_linux/upx > /usr/local/bin/upx \
&& chmod +x /usr/local/bin/upx
COPY --from=builder /usr/local/bin/ace /usr/local/bin/ace
RUN /usr/local/bin/upx --overlay=strip --best /usr/local/bin/ace
The thing is when I build the image I get the following error:
The command '/bin/sh -c /usr/local/bin/upx --overlay=strip --best /usr/local/bin/ace' returned a non-zero code: 127
For some reason, the container doesn't recognize upx as executable! Can anyone give me some pointers?
Upvotes: 2
Views: 2512
Reputation: 1
To get it working with Dockerfile:
(adjust Alpine version to your liking)
FROM alpine:latest as build
RUN apk add --no-cache upx
# Build and use upx as applicable...
Upvotes: 0
Reputation: 421
Turns out there is an apk package for UPX. The easier way to install is:
apk add upx
Upvotes: 3
Reputation: 2533
The archive you have is just the file, so you can't address it by name. If you extract the whole thing (which is just the file) it works. Change the corresponding line in your Dockerfile to the following:
RUN tar -xJOf /tmp/upx.tar.xy upx-${UPX_VERSION}-amd64_linux > /usr/local/bin/upx \
Note that I removed the filename from the archive name.
Upvotes: 0