I'm trying to uncompress a file and delete the original, compressed, archive in my Dockerfile
image build instructions. I need to do this because the file in question is larger than the 2GB
limit set by Github on large file sizes (see here). The solution I'm pursuing is to compress the file (bringing it under the 2GB
limit), and then decompress when I build the application. I know it's bad practice to build large images and plan to integrate a external database into the project but don't have time now to do this.
I've tried various options, but have been unsuccessful.
- Compress the file in
.zip
format and useapt-get
to installunzip
and then decompress the file withunzip
:
FROM python:3.8-slim
#install unzip
RUN apt-get update && apt-get install unzip
WORKDIR /app
COPY /data/databases/file.db.zip /data/databases
RUN unzip /data/databases/file.db.zip && rm -f /data/databases/file.db.zip
COPY ./ ./
This fails with unzip: cannot find or open /data/databases/file.db.zip, /data/databases/file.db.zip.zip or /data/databases/file.db.zip.ZIP.
I don't understand this, as I thought COPY
added files to the image.
- Following this advice, I compressed the large file with
gzip
and tried to use theDocker
nativeADD
command to uncompress it, i.e.:
FROM python:3.8-slim
WORKDIR /app
ADD /data/databases/file.db.gz /data/databases/file.db
COPY ./ ./
While this compiles without error, it does not decompress the file, which I can see using docker exec -t -i clean-dash /bin/bash
to explore the image directory structure. Since the large file is a gzip
file, my understanding is ADD
should decompress it, i.e. from the docs.
How can I solve these requirements?