-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve Dockerfile * chore: Add better comments * chore: Add .dockerignore * chore: Use entrypoint instead of command
- Loading branch information
1 parent
b9be2fd
commit 475d118
Showing
2 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Git metafiles | ||
.git* | ||
|
||
# Editor metafiles | ||
.vscode | ||
|
||
# Docker metafiles | ||
Dockerfile | ||
|
||
# Project metafiles | ||
docs | ||
examples | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,77 @@ | ||
FROM golang:1.22 | ||
# The base image for the supersim image can be modified | ||
# by specifying BASE_IMAGE build argument | ||
ARG BASE_IMAGE=golang:1.22 | ||
|
||
RUN apt-get update && apt-get install -y curl git | ||
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.- | ||
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ | ||
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' | ||
# | ||
# This stage builds the foundry binaries | ||
# | ||
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.- | ||
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ | ||
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' | ||
FROM $BASE_IMAGE AS foundry | ||
|
||
WORKDIR /app | ||
# Make sure foundryup is available | ||
ENV PATH="/root/.foundry/bin:${PATH}" | ||
|
||
# Install required system packages | ||
RUN \ | ||
apt-get update && \ | ||
apt-get install -y curl git | ||
|
||
# Install foundry | ||
RUN curl -L https://foundry.paradigm.xyz | bash | ||
RUN foundryup | ||
|
||
ENV PATH="/root/.foundry/bin:${PATH}" | ||
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.- | ||
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ | ||
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' | ||
# | ||
# This stage builds the project | ||
# | ||
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.- | ||
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ | ||
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' | ||
FROM $BASE_IMAGE AS builder | ||
|
||
RUN foundryup | ||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN go mod tidy | ||
|
||
RUN go build -o supersim cmd/main.go | ||
|
||
CMD ["./supersim"] | ||
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.- | ||
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ | ||
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' | ||
# | ||
# This stage exposes the supersim binary | ||
# | ||
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.- | ||
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ | ||
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' | ||
FROM $BASE_IMAGE AS runner | ||
|
||
# Add foundry & supersim directories to the system PATH | ||
ENV PATH="/root/.foundry/bin:/root/.supersim/bin:${PATH}" | ||
|
||
WORKDIR /app | ||
|
||
# Get the supersim binary from the builder | ||
COPY --from=builder /app/supersim /root/.supersim/bin/supersim | ||
|
||
# Get the anvil binary | ||
COPY --from=foundry /root/.foundry/bin/anvil /root/.foundry/bin/anvil | ||
|
||
# Make sure the required binaries exist | ||
RUN anvil --version | ||
RUN supersim --help | ||
|
||
# We'll use supersim as the entrypoint to our image | ||
# | ||
# This allows the consumers to pass CLI options as the command to docker run: | ||
# | ||
# docker run supersim --help | ||
ENTRYPOINT [ "supersim" ] |