Skip to content

Commit

Permalink
[images/base] Fix binaries being downloaded for only x86_64, it now s…
Browse files Browse the repository at this point in the history
…upports ARM
  • Loading branch information
auguwu committed Oct 25, 2022
1 parent 3eb1e1f commit c09c8ab
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 37 deletions.
61 changes: 45 additions & 16 deletions images/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,60 @@ RUN groupadd -g ${USER_GID} ${USERNAME} && \
# Configure git-lfs
RUN git lfs install --system

# Configure the GitHub CLI
# stuff here
ENV GITHUB_CLI_VERSION="2.18.1"
RUN curl -L -o /tmp/gh.tar.gz https://github.com/cli/cli/releases/download/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_amd64.tar.gz && \
mkdir -p /opt/github/cli && \
tar -xf /tmp/gh.tar.gz -C /opt/github/cli
ENV CODER_CLI_VERSION="0.11.0"
ENV TERRAFORM_VERSION="1.3.3"

# Configure the Coder CLI
ENV CODER_CLI_VERSION="0.10.2"
RUN curl -L -o /tmp/coder.tar.gz https://github.com/coder/coder/releases/download/v${CODER_CLI_VERSION}/coder_${CODER_CLI_VERSION}_linux_amd64.tar.gz && \
mkdir -p /opt/coder/cli && \
tar -xf /tmp/coder.tar.gz -C /opt/coder/cli
# Get current architecture and download software here
# also this looks like shit, i know!
RUN set -eux; \
arch="$(dpkg --print-architecture)"; \
case "${arch}" in \
aarch64|arm64) \
ARCH="arm64" \
GH_DOWNLOAD_URL="https://github.com/cli/cli/releases/download/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_arm64.tar.gz" \
CD_DOWNLOAD_URL="https://github.com/coder/coder/releases/download/v${CODER_CLI_VERSION}/coder_${CODER_CLI_VERSION}_linux_arm64.tar.gz" \
TF_DOWNLOAD_URL="https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_arm64.zip" \
;; \
x86_64|amd64) \
ARCH="amd64" \
GH_DOWNLOAD_URL="https://github.com/cli/cli/releases/download/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_amd64.tar.gz" \
CD_DOWNLOAD_URL="https://github.com/coder/coder/releases/download/v${CODER_CLI_VERSION}/coder_${CODER_CLI_VERSION}_linux_amd64.tar.gz" \
TF_DOWNLOAD_URL="https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" \
;; \
*) \
echo "Unsupported architecture [${arch}]" \
exit 1 \
;; \
esac; \
mkdir -p /opt/coder/cli; \
mkdir -p /opt/github/cli; \
mkdir -p /opt/hashicorp/terraform; \
curl -L -o /tmp/gh.tar.gz ${GH_DOWNLOAD_URL}; \
tar -xf /tmp/gh.tar.gz -C /opt/github/cli; \
curl -L -o /tmp/coder.tar.gz ${CD_DOWNLOAD_URL}; \
tar -xf /tmp/coder.tar.gz -C /opt/coder/cli; \
curl -L -o /tmp/terraform.zip ${TF_DOWNLOAD_URL}; \
unzip -qd /opt/hashicorp/terraform /tmp/terraform.zip; \
mkdir /opt/github/_cli; \
cp -r /opt/github/cli/gh_${GITHUB_CLI_VERSION}_linux_${ARCH} /opt/github/_cli;

# Configure Terraform
ENV TERRAFORM_VERSION="1.3.3"
RUN curl -L -o /tmp/terraform.tar.gz https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \
mkdir -p /opt/hashicorp/terraform && \
unzip -qd /opt/hashicorp/terraform /tmp/terraform.tar.gz
# Do some cleanup for the GitHub CLI path
RUN set -eux; \
ls /opt/github; \
cp /opt/github/_cli/**/LICENSE /opt/github/cli/LICENSE; \
cp -R /opt/github/_cli/**/bin /opt/github/cli/bin; \
cp -R /opt/github/_cli/**/share /opt/github/cli/share; \
rm -rf /opt/github/_cli;

# Cleanup temporary distributions
RUN rm /tmp/*.tar.gz
RUN rm /tmp/*.tar.gz /tmp/*.zip

USER ${USERNAME}
WORKDIR /home/${USERNAME}

# Set paths to coder, gh, and terraform
RUN echo "export PATH=\"\$PATH:/opt/coder/cli\"" >> /home/${USERNAME}/.bashrc
RUN echo "export PATH=\"\$PATH:/opt/hashicorp/terraform\"" >> /home/${USERNAME}/.bashrc
RUN echo "export PATH=\"\$PATH:/opt/github/cli/gh_${GITHUB_CLI_VERSION}_linux_amd64/bin\"" >> /home/${USERNAME}/.bashrc
RUN echo "export PATH=\"\$PATH:/opt/github/cli/bin\"" >> /home/${USERNAME}/.bashrc
2 changes: 1 addition & 1 deletion images/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ This image is the main base for all of the images in this repository. It uses th
| Name | Description | Version |
| --------------- | --------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| GitHub CLI | GitHub’s official command line tool | [v2.18.1](https://github.com/cli/cli/releases/tag/v2.18.1) |
| Coder CLI (OSS) | Remote development environments on your infrastructure provisioned with Terraform | [v0.10.2](https://github.com/coder/coder/releases/tag/v0.10.2) |
| Coder CLI (OSS) | Remote development environments on your infrastructure provisioned with Terraform | [v0.11.0](https://github.com/coder/coder/releases/tag/v0.11.0) |
| Terraform | Automate Infrastructure on Any Cloud | [v1.3.3](https://github.com/hashicorp/terraform/releases/tag/v1.3.3) |
17 changes: 4 additions & 13 deletions images/golang/amd64.Dockerfile → images/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

FROM ghcr.io/auguwu/coder-images/base:latest
# We will build Moby from source, because why not!
FROM ghcr.io/auguwu/coder-images/golang AS build

ENV USERNAME=noel

# Run as root so we don't have to repeat sudo
USER root

ENV GOLANG_VERSION="1.19.2"
RUN curl -L -o /tmp/golang.tar.gz https://go.dev/dl/go${GOLANG_VERSION}linux-amd64.tar.gz && \
mkdir -p /opt/golang && \
tar -xf /tmp/golang.tar.gz -C /opt/golang

RUN rm /tmp/golang.tar.gz
USER ${USERNAME}

RUN echo "export PATH=\"\$PATH:/opt/golang\"" >> /home/${USERNAME}/.bashrc
# Now, we will bring in the built source code in here.
FROM ghcr.io/auguwu/coder-images/base
17 changes: 17 additions & 0 deletions images/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ghcr.io/auguwu/coder-images/docker
This image brings in Docker usage... in a Docker container... yeah, it's weird! But, it works.

## Bundled Software
| Name | Description | Version |
| -------- | -------------------------------------------------- | --------------------------- |
| `docker` | Accelerated, Containerized Application Development | [v20.10.20][docker-release] |

### Docker Plugins
| Name | Description | Version |
| ---------------- | --------------------------------------------------------------- | ------- |
| `docker compose` | Define and run multi-container applications with Docker | [v2.12.2][compose-release] |
| `docker buildx` | Docker CLI plugin for extended build capabilities with BuildKit | [v0.9.1][buildx-release] |

[compose-release]: https://github.com/docker/compose/releases/tag/v2.12.2
[docker-release]: https://github.com/moby/moby/releases/tag/v20.10.20
[buildx-release]: https://github.com/docker/buildx/releases/tag/v0.9.1
Empty file removed images/docker/amd64.Dockerfile
Empty file.
Empty file removed images/docker/arm64.Dockerfile
Empty file.
30 changes: 23 additions & 7 deletions images/golang/arm64.Dockerfile → images/golang/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,35 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

FROM ghcr.io/auguwu/coder-images/base:latest
FROM ghcr.io/auguwu/coder-images/base

ENV USERNAME=noel

# Run as root so we don't have to repeat sudo
USER root

# Put versions in environment variables
ENV GOLANG_VERSION="1.19.2"
RUN curl -L -o /tmp/golang.tar.gz https://go.dev/dl/go${GOLANG_VERSION}linux-arm64.tar.gz && \
mkdir -p /opt/golang && \
tar -xf /tmp/golang.tar.gz -C /opt/golang
ENV GORELEASER_VERSION="1.12.3"
ENV GOLANGCI_VERSION="1.50.1"

RUN rm /tmp/golang.tar.gz
USER ${USERNAME}
# Install packages here.
RUN set -eux; \
arch="$(dpkg --print-architecture)"; \
case "${arch}" in \
aarch64|arm64) \
ARCH="arm64"; \
GO_DOWNLOAD_URL="https://go.dev/dl/go${GOLANG_VERSION}linux-arm64.tar.gz" \
GORELEASER_DOWNLOAD_URL="https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/goreleaser_Linux_arm64.tar.gz" \
GOLANGCI_DOWNLOAD_URL="https://github.com/golangci/golangci-lint/releases/download/v${GOLANG_VERSION}/golangci-lint-${GOLANGCI_VERSION}-linux-arm64.tar.gz" \
;; \
x86_64|amd64) \
ARCH="amd64"; \
GO_DOWNLOAD_URL="https://go.dev/dl/go${GOLANG_VERSION}linux-amd64.tar.gz" \
GORELEASER_DOWNLOAD_URL="https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/goreleaser_Linux_amd64.tar.gz" \
GOLANGCI_DOWNLOAD_URL="https://github.com/golangci/golangci-lint/releases/download/v${GOLANG_VERSION}/golangci-lint-${GOLANGCI_VERSION}-linux-amd64.tar.gz" \
;; \
esac;

RUN echo "export PATH=\"\$PATH:/opt/golang\"" >> /home/${USERNAME}/.bashrc
#RUN rm /tmp/*.tar.gz
USER ${USERNAME}

0 comments on commit c09c8ab

Please sign in to comment.