liquibase / liquibase-package-manager

lpm - Liquibase package manager
Apache License 2.0
11 stars 12 forks source link

"lpm update" fails inside docker build with alpine-linux base image #207

Closed tapanhalani closed 1 year ago

tapanhalani commented 1 year ago

Describe the bug After stumbling upon this issue (https://github.com/liquibase/docker/issues/171), I started working on installing lpm (v0.2.0) and liquibase (v4.19.0) while building a docker image based on alpine-linux (eclipse-temurin:8-jre-alpine) . But the docker build fails with the following error:

Step 8/20 : ARG LIQUIBASE_VERSION=4.19.0
 ---> Running in 8d950e042c3b
Removing intermediate container 8d950e042c3b
 ---> 703d3c06ac1f
Step 9/20 : ARG LPM_VERSION=0.2.0
 ---> Running in 176d13b4fc35
Removing intermediate container 176d13b4fc35
 ---> 473a81914799
Step 10/20 : ARG LB_SHA256=2ec24cacf1dc6794cde139de9778854839ee1d3fa9c134fefa92157401e57134
 ---> Running in 4931741dd23f
Removing intermediate container 4931741dd23f
 ---> f971ca606116
Step 11/20 : RUN set -x   && wget -q -O liquibase-${LIQUIBASE_VERSION}.tar.gz "https://github.com/liquibase/liquibase/releases/download/v${LIQUIBASE_VERSION}/liquibase-${LIQUIBASE_VERSION}.tar.gz"   && echo "$LB_SHA256  liquibase-${LIQUIBASE_VERSION}.tar.gz" | sha256sum -c -   && tar -xzf liquibase-${LIQUIBASE_VERSION}.tar.gz   && rm liquibase-${LIQUIBASE_VERSION}.tar.gz
 ---> Running in 03a4bdc7d61b
+ wget -q -O liquibase-4.19.0.tar.gz https://github.com/liquibase/liquibase/releases/download/v4.19.0/liquibase-4.19.0.tar.gz
+ echo '2ec24cacf1dc6794cde139de9778854839ee1d3fa9c134fefa92157401e57134  liquibase-4.19.0.tar.gz'
+ sha256sum -c -
liquibase-4.19.0.tar.gz: OK
+ tar -xzf liquibase-4.19.0.tar.gz
+ rm liquibase-4.19.0.tar.gz
Removing intermediate container 03a4bdc7d61b
 ---> 614bda2eb46a
Step 12/20 : RUN mkdir /liquibase/bin     && wget -q -O lpm.zip "https://github.com/liquibase/liquibase-package-manager/releases/download/v${LPM_VERSION}/lpm-${LPM_VERSION}-linux.zip"     && unzip lpm.zip -d bin/     && rm lpm.zip
 ---> Running in e211d9fe6d60
Archive:  lpm.zip
  inflating: bin/lpm                 
Removing intermediate container e211d9fe6d60
 ---> f483dbbd0521
Step 13/20 : ENV LIQUIBASE_HOME /liquibase
 ---> Running in 0d4c6010a863
Removing intermediate container 0d4c6010a863
 ---> 45cfedb3a773
Step 14/20 : RUN lpm update     && /liquibase/liquibase --version
 ---> Running in fdc5fd97d8f4
Unable to download from https://raw.githubusercontent.com/liquibase/liquibase-package-manager/master/internal/app/packages.json

The documentation of lpm shows an extra flag -p, whose default value is the same as given in the error. I don't know how to fix this, so any help here is highly appreciated. Thank you.

Expected behavior The docker build should succeed

Desktop (please complete the following information):

mcred commented 1 year ago

Are you able to finish the container build without the lpm update step and then use an interactive shell in the container to see if lpm succeeds then or if you can reach the URL for the package.json file with wget? I've not run into this issue before but also have not done any testing in alpine linux. I know binaries behave differently there due to different system libraries.

tapanhalani commented 1 year ago

@mcred If I comment out the "lpm update" step, the build succeeds. Here are the logs:

Step 12/20 : RUN mkdir /liquibase/bin     && wget -q -O lpm.zip "https://github.com/liquibase/liquibase-package-manager/releases/download/v${LPM_VERSION}/lpm-${LPM_VERSION}-linux.zip"     && unzip lpm.zip -d bin/     && rm lpm.zip
 ---> Running in ce67d90ae882
Archive:  lpm.zip
  inflating: bin/lpm                 
Removing intermediate container ce67d90ae882
 ---> bec1ca4b31c8
Step 13/20 : ENV LIQUIBASE_HOME /liquibase
 ---> Running in c9dad6282c89
Removing intermediate container c9dad6282c89
 ---> 931355c55146
Step 14/20 : RUN /liquibase/liquibase --version
 ---> Running in 4f8cb8e909f2
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ## 
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ## 
##  Free schema change activity reports at        ##
##      https://hub.liquibase.com                 ##
##                                                ##
####################################################
Starting Liquibase at 18:29:27 (version 4.19.0 #6648 built at 2023-01-17 15:02+0000)
Liquibase Home: /liquibase
Java Home /opt/java/openjdk (Version 1.8.0_362)
Libraries:
- internal/lib/commons-collections4.jar: Apache Commons Collections 4.4.0 By The Apache Software Foundation
- internal/lib/commons-lang3.jar: Apache Commons Lang 3.12.0 By The Apache Software Foundation
- internal/lib/commons-text.jar: Apache Commons Text 1.10.0 By The Apache Software Foundation
- internal/lib/connector-api.jar: J2EE Connector Architecture API Specification 1.5 By Sun Microsystems, Inc.
- internal/lib/h2.jar: H2 Database Engine 2.1.214 By H2 Group
- internal/lib/hsqldb.jar: HSQLDB 2.7.1 By The HSQL Development Group
- internal/lib/jaxb-api.jar: jaxb-api 2.3.1 By Oracle Corporation
- internal/lib/jaxb-core.jar: JAXB Core 4.0.1 By Eclipse Foundation
- internal/lib/jaxb-runtime.jar: JAXB Runtime 4.0.1 By Eclipse Foundation
- internal/lib/jaybird.jar: Jaybird 4.0.8.java8 (build: variant=jaybird tag=v4.0.8 date=202211271142) By Firebird project
- internal/lib/jcc.jar: IBM JCC JDBC 4 Driver 1.4.0 By IBM
- internal/lib/liquibase-commercial.jar: Commercial Liquibase Functionality 4.19.0 By Liquibase
- internal/lib/mariadb-java-client.jar: mariadb-java-client 3.1.0 By mariadb.com
- internal/lib/mssql-jdbc.jar: Microsoft JDBC Driver for SQL Server 11.2.1 By Microsoft Corporation
- internal/lib/ojdbc8.jar: JDBC 21.8.0.0.0 By Oracle Corporation
- internal/lib/opencsv.jar: opencsv 5.7.1
- internal/lib/picocli.jar: picocli 4.7.0 By Remko Popma
- internal/lib/postgresql.jar: PostgreSQL JDBC Driver 42.5.1 By PostgreSQL Global Development Group
- internal/lib/snakeyaml.jar: SnakeYAML 1.33.0
- internal/lib/snowflake-jdbc.jar: snowflake-jdbc 3.13.26
- internal/lib/sqlite-jdbc.jar: SQLite JDBC 3.40.0.0

Liquibase Version: 4.19.0
Liquibase Open Source 4.19.0 by Liquibase
Removing intermediate container 4f8cb8e909f2
 ---> c6ef40410b65
Step 15/20 : COPY --chown=liquibase:liquibase docker-entrypoint.sh /liquibase/
 ---> 81d76aff607d
Step 16/20 : COPY --chown=liquibase:liquibase liquibase.docker.properties /liquibase/
 ---> f1996e97a54d
Step 17/20 : VOLUME /liquibase/classpath
 ---> Running in ce05b12a461b
Removing intermediate container ce05b12a461b
 ---> 7b0b16e1dfd0
Step 18/20 : VOLUME /liquibase/changelog
 ---> Running in 5bf8bc304469
Removing intermediate container 5bf8bc304469
 ---> 7e46208d2a79
Step 19/20 : ENTRYPOINT ["/liquibase/docker-entrypoint.sh"]
 ---> Running in 86d2e827cbfb
Removing intermediate container 86d2e827cbfb
 ---> c3615b490271
Step 20/20 : CMD ["--help"]
 ---> Running in 55d521dff4dc
Removing intermediate container 55d521dff4dc
 ---> 2248f21108c3
Successfully built 2248f21108c3
Successfully tagged tapanhalani/liquibase:temurine-alpine

If I exec into the container using bash/sh and try running "lpm update" manually, sometimes it fail with the same error, sometimes it work successfully. But wget to the same github URL mentioned in the error works successfully always, as follows:

$ docker run -it tapanhalani/liquibase:temurine-alpine /bin/bash
/liquibase $ lpm update
Package manifest updated from https://raw.githubusercontent.com/liquibase/liquibase-package-manager/master/internal/app/packages.json
/liquibase $ lpm update
Unable to download from https://raw.githubusercontent.com/liquibase/liquibase-package-manager/master/internal/app/packages.json
/liquibase $ wget https://raw.githubusercontent.com/liquibase/liquibase-package-manager/master/internal/app/packages.json
--2023-01-30 18:35:21--  https://raw.githubusercontent.com/liquibase/liquibase-package-manager/master/internal/app/packages.json
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 2606:50c0:8001::154, 2606:50c0:8003::154, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 461566 (451K) [text/plain]
Saving to: 'packages.json'

packages.json                     100%[=============================================================>] 450.75K   394KB/s    in 1.1s    

2023-01-30 18:35:24 (394 KB/s) - 'packages.json' saved [461566/461566]
jnewton03 commented 1 year ago

@tapanhalani that really seems like a temporary network issue or something. Is it still exhibiting the same behavior?