Skip to content

Commit 377e74d

Browse files
author
Mike Morris
committed
Dockerfile enhancements
Update apt-get command to perform cleanup, shrinks existing image by about 20MB Use ARG instead of ENV for LIQUIBASE_VERSION. This enables you to pass the Liquibase version at image build time and create tagged builds easily. Also avoids setting an extra env variable during docker run. Example tagged build command: docker build . --build-arg LIQUIBASE_VERSION=3.8.5 -t liquibase/docker:3.8.5 Simplify download logic and avoid the intermediate file Use chmod safely (755 vs 777)
1 parent 7d94cc3 commit 377e74d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ MAINTAINER Datical <[email protected]>
66
RUN apt-get update \
77
&& apt-get install -yq --no-install-recommends \
88
libmariadb-java \
9-
libpostgresql-jdbc-java
9+
libpostgresql-jdbc-java \
10+
&& apt-get autoclean \
11+
&& apt-get clean \
12+
&& rm -rf /var/*/apt/*
1013
# /usr/share/java/mariadb-java-client.jar
1114
# /usr/share/java/postgresql.jar
1215

@@ -19,16 +22,14 @@ WORKDIR /liquibase
1922
USER liquibase
2023

2124
# Latest Liquibase Release Version
22-
ENV LIQUIBASE_VERSION 3.8.6
25+
ARG LIQUIBASE_VERSION=3.8.6
2326

2427
# Download, install, clean up
2528
RUN set -x \
26-
&& curl -L https://github.com/liquibase/liquibase/releases/download/v${LIQUIBASE_VERSION}/liquibase-${LIQUIBASE_VERSION}.tar.gz -o liquibase-core-${LIQUIBASE_VERSION}-bin.tar.gz \
27-
&& tar -xzf liquibase-core-${LIQUIBASE_VERSION}-bin.tar.gz \
28-
&& rm liquibase-core-${LIQUIBASE_VERSION}-bin.tar.gz
29+
&& curl -L https://github.com/liquibase/liquibase/releases/download/v${LIQUIBASE_VERSION}/liquibase-${LIQUIBASE_VERSION}.tar.gz | tar -xzf -
2930

3031
# Set liquibase to executable
31-
RUN chmod 777 /liquibase
32+
RUN chmod 755 /liquibase
3233

3334
ENTRYPOINT ["/liquibase/liquibase"]
3435
CMD ["--help"]

0 commit comments

Comments
 (0)