package df

const (
	goDfTmpl = `
# syntax=docker/dockerfile:1

# Create a stage for building the application.
FROM ttl.sh/go-base:dev-5h@sha256:74bc47b1f9efc4c2d0ea20cf092c7b2d0d2b5a71713c1cb7addb24e173f10993 AS build
WORKDIR /src

COPY . /src

RUN mkdir -p /tmp

# Build the application.
# source code into the container.
{{ if (.Hermetic)}}
RUN CGO_ENABLED=0 go build -mod=vendor -o /bin/server .
{{ end }}
{{ if ne (.Hermetic) true}}
RUN CGO_ENABLED=0 go build -o /bin/server .
{{ end }}
FROM ttl.sh/go-base:5h@sha256:c5343ac7f8bc74420ed919f00711f9a0c3f94f841938ad43838b938432a1f433 AS final

# Copy the executable from the "build" stage.
COPY --from=build /bin/server /bin/

# Expose the port that the application listens on.
EXPOSE 8080

# What the container should run when it is started.
ENTRYPOINT [ "/bin/server" ]
`
)

const (
	rustDfTmpl = `
# syntax=docker/dockerfile:1

# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/go/dockerfile-reference/

# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7

ARG APP_NAME=sampple-rust-app
#############################
# Create a stage for building the application.

FROM ttl.sh/rust-base:dev-7h@sha256:4da36557b97b49098d29d5b72113ddfffa135f9e9e00c32300ac7cfb06bd91a0 AS build
RUN mkdir -p /tmp
ARG APP_NAME
WORKDIR /app

COPY . .

# Build the application.
RUN cargo build --locked --release && \
cp ./target/release/$APP_NAME /bin/app

################################################################################
# Create a new stage for running the application that contains the minimal
# runtime dependencies for the application. This often uses a different base
# image from the build stage where the necessary files are copied from the build
# stage.

FROM ttl.sh/rust-base:19h@sha256:3834849608901a455c808b70607df6f32e898b38d784551d0b9bb6e1b14c1af6 AS final

# Copy the executable from the "build" stage.
COPY --from=build /bin/app /bin/

# What the container should run when it is started.
CMD ["/bin/app"]
`
)

const (
	pythonDfTmpl = `
FROM ttl.sh/python-base:2h@sha256:2f45fcf729131928a4fd7ffeb9a3bcdac85cb6c9de88ef4639054b6b1717abe4 as base

# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1

# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1

# Dependencies have been saved in vendor. It is generated by:
# poetry export -f requirements.txt --output requirements.txt
# pip3 install -r requirements.txt -t vendor
{{ if (.Hermetic)}}
ENV PYTHONPATH=vendor
{{ end }}

WORKDIR /app

{{ if ne (.Hermetic) true}}
# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
# Leverage a bind mount to requirements.txt to avoid having to copy them into
# into this layer.
RUN --mount=type=cache,target=/root/.cache/pip \
    --mount=type=bind,source=requirements.txt,target=requirements.txt \
    python -m pip install -r requirements.txt
{{ end }}

# Switch to the non-privileged user to run the application.

# Copy the source code into the container.
COPY . .

# Expose the port that the application listens on.
EXPOSE 5000

# Run the application.
CMD python app/app.py
`
)
