minamijoyo / tfupdate

Update version constraints in your Terraform configurations
MIT License
556 stars 23 forks source link

In-compatible with Alpine #22

Closed osulli closed 4 years ago

osulli commented 4 years ago

Unable to use released binaries in Alpine.

# Dockerfile
FROM python:3.7-alpine3.10

WORKDIR /app

ARG TFUPDATE_VERSION
RUN curl -L https://github.com/minamijoyo/tfupdate/releases/download/v${TFUPDATE_VERSION}/tfupdate_${TFUPDATE_VERSION}_linux_amd64.tar.gz -o tfupdate.tar.gz && \
    tar -xvzf tfupdate.tar.gz tfupdate && \
    rm tfupdate.tar.gz && \
    chmod +x tfupdate && \
    chown root:root tfupdate && \
    mv tfupdate /usr/bin/tfupdate && \
    tfupdate -v

This will error with command not found. If you then exec into the image, the proper error is bash: .: /usr/bin/tfupdate: cannot execute binary file

Please could you begin publishing an Alpine generated binary as we don't want to compile from source.

Thanks

minamijoyo commented 4 years ago

@osulli Thank you for reporting the issue! I can reproduce it. I think it's probably go build options problem. I'll check it later.

As a workaround, you can copy the tfupdate binary from the minamijoyo/tfupdate docker image using the docker multi-stage build. This image is build automatically in the release process using the Dockerfile in the repository root ,which is based on alpine. So, the binary in the image is compatible with alpine.

https://github.com/minamijoyo/tfupdate/blob/v0.4.0/Dockerfile

ARG TFUPDATE_VERSION
FROM minamijoyo/tfupdate:${TFUPDATE_VERSION} AS tfupdate

FROM python:3.7-alpine3.10

WORKDIR /app

COPY --from=tfupdate /usr/local/bin/tfupdate /usr/bin/tfupdate
RUN tfupdate -v
$ docker build --build-arg TFUPDATE_VERSION=0.4.0 -t tfupdate-debug .
Sending build context to Docker daemon  2.048kB
Step 1/6 : ARG TFUPDATE_VERSION
Step 2/6 : FROM minamijoyo/tfupdate:${TFUPDATE_VERSION} AS tfupdate
0.4.0: Pulling from minamijoyo/tfupdate
21c83c524219: Already exists
6f2a13c6c68b: Pull complete
8630059c3f9d: Pull complete
24cc0c72fa73: Pull complete
Digest: sha256:874aa427dbe6a899a6cf084825d6ffbfdb30965f100b82d77110e9a41546aeb1
Status: Downloaded newer image for minamijoyo/tfupdate:0.4.0
 ---> dd4cc98c6dd8
Step 3/6 : FROM python:3.7-alpine3.10
 ---> f1bb026b263f
Step 4/6 : WORKDIR /app
 ---> Using cache
 ---> 8db601c86931
Step 5/6 : COPY --from=tfupdate /usr/local/bin/tfupdate /usr/bin/tfupdate
 ---> acfdc6369701
Step 6/6 : RUN tfupdate -v
 ---> Running in bfd7ab669e95
0.4.0
Removing intermediate container bfd7ab669e95
 ---> 537ad0c379ac
Successfully built 537ad0c379ac
Successfully tagged tfupdate-debug:latest
$ docker run -it --rm tfupdate-debug tfupdate -v
0.4.0
minamijoyo commented 4 years ago

@osulli Fixed in v0.4.1. Give it a try!

[tfupdate@master|✔]$ docker run -it --rm -v $(pwd)/tmp:/work alpine:3.10 /bin/sh

/ # apk add --no-cache curl
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/4) Installing ca-certificates (20191127-r2)
(2/4) Installing nghttp2-libs (1.39.2-r1)
(3/4) Installing libcurl (7.66.0-r0)
(4/4) Installing curl (7.66.0-r0)
Executing busybox-1.30.1-r3.trigger
Executing ca-certificates-20191127-r2.trigger
OK: 7 MiB in 18 packages

/ # curl -L https://github.com/minamijoyo/tfupdate/releases/download/v0.4.1/tfupdate_0.4.1_linux_amd64.tar.gz -o tfupd
ate.tar.gz && tar -xvzf tfupdate.tar.gz tfupdate
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   646  100   646    0     0   1512      0 --:--:-- --:--:-- --:--:--  1509
100 4610k  100 4610k    0     0  1567k      0  0:00:02  0:00:02 --:--:-- 2809k
tfupdate

/ # ./tfupdate -v
0.4.1