-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3273cf
commit 5122b1c
Showing
1 changed file
with
36 additions
and
34 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 |
---|---|---|
@@ -1,51 +1,53 @@ | ||
FROM golang:1.23 as builder | ||
FROM golang:1.23 | ||
|
||
# Install dependencies and CLI tools in a single layer to minimize build time | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
# Install Docker CLI and other dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg \ | ||
lsb-release \ | ||
bash \ | ||
unzip && \ | ||
# Install Docker CLI | ||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ | ||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" \ | ||
| tee /etc/apt/sources.list.d/docker.list > /dev/null && \ | ||
apt-get update && apt-get install -y --no-install-recommends docker-ce-cli && \ | ||
# Install AWS CLI | ||
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ | ||
unzip awscliv2.zip && ./aws/install && rm -rf aws awscliv2.zip && \ | ||
# Install GCP CLI | ||
curl -o /tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz && \ | ||
mkdir -p /usr/local/gcloud && tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz && \ | ||
/usr/local/gcloud/google-cloud-sdk/install.sh && \ | ||
# Install Azure CLI | ||
curl -sL https://aka.ms/InstallAzureCLIDeb | bash && \ | ||
# Clean up to reduce image size | ||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* | ||
|
||
# Set environment variables for GCP CLI | ||
unzip | ||
|
||
# Add Docker's official GPG key | ||
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | ||
|
||
# Set up the Docker repository | ||
RUN echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \ | ||
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
|
||
# Install Docker CE CLI | ||
RUN apt-get update && apt-get install -y docker-ce-cli | ||
|
||
# Install AWS CLI v2 | ||
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ | ||
unzip awscliv2.zip && \ | ||
./aws/install && \ | ||
rm -rf aws awscliv2.zip | ||
|
||
# Install GCP CLI | ||
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz | ||
|
||
RUN mkdir -p /usr/local/gcloud \ | ||
&& tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz \ | ||
&& /usr/local/gcloud/google-cloud-sdk/install.sh | ||
|
||
ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin | ||
|
||
# Set up Go environment | ||
# Install Azure CLI | ||
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash | ||
|
||
WORKDIR /go/src/app | ||
COPY . . | ||
|
||
# Build Go application in builder stage | ||
# Build the Go application | ||
RUN go build -o enigma main.go | ||
|
||
# Create a minimal final image without build dependencies | ||
FROM golang:1.23 as runner | ||
WORKDIR /go/src/app | ||
|
||
# Copy the binary from the builder stage | ||
COPY --from=builder /go/src/app/enigma /go/src/app/enigma | ||
COPY --from=builder /go/src/app/entrypoint.sh /go/src/app/entrypoint.sh | ||
RUN chmod +x enigma | ||
|
||
# Add executable permissions to the entrypoint script | ||
RUN chmod +x /go/src/app/entrypoint.sh | ||
|
||
RUN chmod +x entrypoint.sh | ||
# Set entrypoint to the shell script | ||
ENTRYPOINT ["/go/src/app/entrypoint.sh"] | ||
ENTRYPOINT ["/go/src/app/entrypoint.sh"] |