Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockerfile frontend examples #145

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions dockerfiles/frontends/v1.4-heredocs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# syntax=docker/dockerfile:1.4
FROM ubuntu as old-way

RUN apt-get update && \
apt-get install -y curl && \
apt-get clean


FROM ubuntu as new-way

RUN <<EOF
apt-get update
apt-get install -y curl
EOF
19 changes: 19 additions & 0 deletions dockerfiles/frontends/v1.4-link/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# syntax=docker/dockerfile:1.4
# COPY/ADD can now include files in a layer without invalidating layer cache

# Example 1: if images change, RUN layer isn't re-run
# Example 2: if only a --link layer needs updating, FROM and other layers aren't needed in cache

FROM alpine as stage1

# if these files change, the RUN layer below is still valid and cache is used
COPY /static/images /app/images


FROM alpine as stage2

# If this line changes, the COPY --link isn't affected
RUN apk add --no-cache curl


COPY --link --from=stage1 /app/images /app/images
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions dockerfiles/frontends/v1.6-add-git/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# syntax=docker/dockerfile:1.6
# ADD can now clone git repos without git installed
# https://docs.docker.com/engine/reference/builder/#adding-a-git-repository-add-git-ref-dir

#######
# EXAMPLE 1
#######
FROM alpine as clone-public-repo

# clone public git repo
# also keep the .git directory, which is off by default
ADD --keep-git-dir=true https://github.com/moby/buildkit.git#v0.10.1 /buildkit

#######
# EXAMPLE 2
#######
FROM alpine as clone-private-repo

# clone private git repo
# This assumes you have a ssh key that's needed to access the private repo
# use `docker build --ssh default .` to pass the ssh-agent keys
ADD [email protected]:BretFisher/autodeploy.git /autodeploy