Skip to content

Commit ef026ad

Browse files
committed
feat: support multi-architecture builds for Go in Dockerfiles and update workflows
Signed-off-by: Aaron Wislang <aaron.wislang@microsoft.com>
1 parent 51bd511 commit ef026ad

File tree

8 files changed

+75
-14
lines changed

8 files changed

+75
-14
lines changed

.devcontainer/ai-container/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# Use a minimal base image designed for dev containers
22
FROM mcr.microsoft.com/devcontainers/base:ubuntu
33

4+
ARG TARGETARCH=amd64
5+
ENV GO_VERSION=1.25.0
6+
47
# Install Go (match default-container)
5-
RUN wget -q -O go.tar.gz https://go.dev/dl/go1.25.0.linux-amd64.tar.gz \
8+
RUN case "${TARGETARCH}" in \
9+
amd64) GO_ARCH=amd64 ;; \
10+
arm64) GO_ARCH=arm64 ;; \
11+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
12+
esac \
13+
&& wget -q -O go.tar.gz "https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" \
614
&& tar -C /usr/local -xzf go.tar.gz \
715
&& rm go.tar.gz
816
ENV PATH="/usr/local/go/bin:${PATH}"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# AI Dev Container
2+
3+
This container image powers the **AI (Container)** devcontainer configuration under `.devcontainer/ai-container`.
4+
5+
## Building Locally
6+
7+
### Docker / Buildx
8+
9+
```bash
10+
docker buildx build --platform linux/amd64,linux/arm64/v8 -f Dockerfile -t ghcr.io/your-org/ai:latest .
11+
```
12+
13+
### macOS container CLI
14+
15+
On Apple Silicon hosts you can build a native arm64 variant with the macOS `container` CLI:
16+
17+
```bash
18+
container build --build-arg TARGETARCH=arm64 --platform linux/arm64/v8 --file Dockerfile .
19+
```
20+
21+
Adjust the tag or output options (`--tag`, `--output`) to suit your workflow.

.devcontainer/codex-container/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
# Use a minimal base image designed for dev containers
22
FROM mcr.microsoft.com/devcontainers/base:ubuntu
33

4+
ARG TARGETARCH=amd64
5+
ENV GO_VERSION=1.25.0
6+
47
# Install Go
58
# Install latest Go version
6-
RUN wget -q -O go.tar.gz https://go.dev/dl/go1.25.0.linux-amd64.tar.gz \
9+
RUN case "${TARGETARCH}" in \
10+
amd64) GO_ARCH=amd64 ;; \
11+
arm64) GO_ARCH=arm64 ;; \
12+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
13+
esac \
14+
&& wget -q -O go.tar.gz "https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" \
715
&& tar -C /usr/local -xzf go.tar.gz \
816
&& rm go.tar.gz
917
ENV PATH="/usr/local/go/bin:${PATH}"
@@ -23,4 +31,4 @@ RUN npm install -g @openai/codex
2331
ENV OPENAI_API_KEY=""
2432

2533
# [Optional] Define a default command if you want the container to do something specific on startup
26-
CMD ["bash"]
34+
CMD ["bash"]

.devcontainer/default-container/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# Use a minimal base image designed for dev containers
22
FROM mcr.microsoft.com/devcontainers/base:ubuntu
33

4+
ARG TARGETARCH=amd64
5+
ENV GO_VERSION=1.25.0
6+
47
# Install Go
58
# Install any project-specific tools not available as Dev Container Features
69
# Example: Installing a specific version of a tool
710
# Install latest Go version
8-
RUN wget -q -O go.tar.gz https://go.dev/dl/go1.25.0.linux-amd64.tar.gz \
11+
RUN case "${TARGETARCH}" in \
12+
amd64) GO_ARCH=amd64 ;; \
13+
arm64) GO_ARCH=arm64 ;; \
14+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
15+
esac \
16+
&& wget -q -O go.tar.gz "https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" \
917
&& tar -C /usr/local -xzf go.tar.gz \
1018
&& rm go.tar.gz
1119
ENV PATH="/usr/local/go/bin:${PATH}"
@@ -17,4 +25,4 @@ ENV PATH="/usr/local/go/bin:${PATH}"
1725
# ENV MY_CUSTOM_VAR="hello"
1826

1927
# [Optional] Define a default command if you want the container to do something specific on startup
20-
# CMD ["bash"]
28+
# CMD ["bash"]

.devcontainer/llm-container/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# Use a minimal base image designed for dev containers
22
FROM mcr.microsoft.com/devcontainers/base:ubuntu
33

4+
ARG TARGETARCH=amd64
5+
ENV GO_VERSION=1.25.0
6+
47
# Install Go (match default-container)
5-
RUN wget -q -O go.tar.gz https://go.dev/dl/go1.25.0.linux-amd64.tar.gz \
8+
RUN case "${TARGETARCH}" in \
9+
amd64) GO_ARCH=amd64 ;; \
10+
arm64) GO_ARCH=arm64 ;; \
11+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
12+
esac \
13+
&& wget -q -O go.tar.gz "https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" \
614
&& tar -C /usr/local -xzf go.tar.gz \
715
&& rm go.tar.gz
816
ENV PATH="/usr/local/go/bin:${PATH}"

.devcontainer/wassette-container/Dockerfile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# Base devcontainer image
22
FROM mcr.microsoft.com/devcontainers/base:ubuntu
33

4+
ARG TARGETARCH=amd64
5+
ENV GO_VERSION=1.25.0
6+
47
# Install Go (match default-container)
5-
RUN wget -q -O go.tar.gz https://go.dev/dl/go1.25.0.linux-amd64.tar.gz \
8+
RUN case "${TARGETARCH}" in \
9+
amd64) GO_ARCH=amd64 ;; \
10+
arm64) GO_ARCH=arm64 ;; \
11+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
12+
esac \
13+
&& wget -q -O go.tar.gz "https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" \
614
&& tar -C /usr/local -xzf go.tar.gz \
715
&& rm go.tar.gz
816
ENV PATH="/usr/local/go/bin:${PATH}"
@@ -15,11 +23,10 @@ RUN set -eux; \
1523
apt-get update; \
1624
apt-get install -y --no-install-recommends ca-certificates curl tar git; \
1725
rm -rf /var/lib/apt/lists/*; \
18-
arch="$(uname -m)"; \
19-
case "$arch" in \
20-
x86_64|amd64) cpu="amd64" ;; \
21-
aarch64|arm64) cpu="arm64" ;; \
22-
*) echo "Unsupported architecture: $arch"; exit 1 ;; \
26+
case "${TARGETARCH}" in \
27+
amd64) cpu="amd64" ;; \
28+
arm64) cpu="arm64" ;; \
29+
*) echo "Unsupported architecture: ${TARGETARCH}"; exit 1 ;; \
2330
esac; \
2431
ver="${WASSETTE_VERSION#v}"; \
2532
asset="wassette_${ver}_linux_${cpu}.tar.gz"; \
@@ -38,4 +45,3 @@ CMD ["bash"]
3845
# Provide a default MCP config inside the image for VS Code
3946
# The devcontainer.json will copy this into the workspace's .vscode on create if missing
4047
COPY mcp.json /opt/wassette/mcp.json
41-

.github/workflows/build-all-devcontainers.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
with:
8686
context: ./.devcontainer/${{ matrix.devcontainer }}
8787
file: ./.devcontainer/${{ matrix.devcontainer }}/Dockerfile
88+
platforms: linux/amd64,linux/arm64/v8
8889
push: ${{ github.event_name != 'pull_request' }}
8990
tags: ${{ steps.meta.outputs.tags }}
9091
labels: ${{ steps.meta.outputs.labels }}
@@ -94,4 +95,4 @@ jobs:
9495
- name: Output image details
9596
run: |
9697
echo "Built devcontainer: ${{ matrix.devcontainer }}"
97-
echo "Tags: ${{ steps.meta.outputs.tags }}"
98+
echo "Tags: ${{ steps.meta.outputs.tags }}"

.github/workflows/build-single-devcontainer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
with:
6565
context: ./.devcontainer/${{ github.event.inputs.devcontainer_choice }}
6666
file: ./.devcontainer/${{ github.event.inputs.devcontainer_choice }}/Dockerfile
67+
platforms: linux/amd64,linux/arm64/v8
6768
push: true
6869
tags: ${{ steps.meta.outputs.tags }}
6970
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)