Skip to content

Instantly share code, notes, and snippets.

@AlexRogalskiy
Forked from mikenoethiger/Dockerfile
Created September 13, 2021 02:48
Show Gist options
  • Save AlexRogalskiy/b18611c0530b2503e22784aeb6a9b426 to your computer and use it in GitHub Desktop.
Save AlexRogalskiy/b18611c0530b2503e22784aeb6a9b426 to your computer and use it in GitHub Desktop.
Dockerfile demonstrating multi-stage build
FROM mysql:5 as sqldump
WORKDIR /home
# Copy required artifacts and source code
COPY initial.sql .
COPY java-program ./java-program
COPY sqldump.sh .
# Copy jdk11 and gradle from the gradle:jdk11 image
COPY --from=gradle:jdk11 /opt/java /opt/java
COPY --from=gradle:jdk11 /opt/gradle /opt/gradle
# Set environment variable
ARG MYSQL_ROOT_PASSWORD=root
# Execute the build script which will generate the sql dump
RUN chmod u+x sqldump.sh && /bin/bash -c ./sqldump.sh
FROM mysql:5
COPY --from=sqldump /home/dump.sql.gz /docker-entrypoint-initdb.d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment