Skip to content

Commit 3f40512

Browse files
committed
first commit
1 parent f5a983e commit 3f40512

File tree

4 files changed

+158
-0
lines changed

4 files changed

+158
-0
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.git/
2+
.github/
3+
README.md
4+
LICENSE

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
- package-ecosystem: "docker"
8+
directory: "/"
9+
schedule:
10+
interval: "daily"

.github/workflows/cd.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: 'CD (multi arch)'
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
7+
jobs:
8+
docker-buildx:
9+
runs-on: ubuntu-latest
10+
steps:
11+
-
12+
name: Checkout
13+
uses: actions/checkout@v3
14+
-
15+
name: Docker meta
16+
id: meta
17+
uses: docker/metadata-action@v4
18+
with:
19+
images: |
20+
ghcr.io/raonigabriel/coder-core
21+
tags: |
22+
type=ref,event=branch
23+
type=ref,event=pr
24+
type=semver,pattern={{version}}
25+
type=semver,pattern={{major}}.{{minor}}
26+
-
27+
name: Set up QEMU
28+
uses: docker/setup-qemu-action@v2
29+
with:
30+
platforms: arm64
31+
-
32+
name: Set up Docker Buildx
33+
id: buildx
34+
uses: docker/setup-buildx-action@v2
35+
with:
36+
install: true
37+
-
38+
name: Login to GitHub Container Registry
39+
uses: docker/login-action@v2
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
-
45+
name: Build and push
46+
uses: docker/build-push-action@v3
47+
with:
48+
context: .
49+
platforms: linux/amd64,linux/arm64
50+
push: true
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# This is a hack to setuo alternate architecture names
2+
# For this to work, it needs to be built using docker 'buildx'
3+
FROM ghcr.io/raonigabriel/coder-core:latest AS linux-amd64
4+
ARG ALT_ARCH=x64
5+
6+
FROM ghcr.io/raonigabriel/coder-core:latest AS linux-arm64
7+
ARG ALT_ARCH=arm64
8+
9+
# This inherits from the hack above
10+
FROM ${TARGETOS}-${TARGETARCH} AS builder
11+
ARG TARGETARCH
12+
ARG CLOUDFLARE_VERSION=2022.9.0
13+
ARG OPENVSCODE_VERSION=v1.71.0
14+
15+
# Install npm, nodejs and some tools required to build native node modules
16+
RUN sudo apk --no-cache add npm build-base libsecret-dev python3 wget
17+
18+
# Setup a dummy project
19+
RUN cd /tmp && \
20+
npm init -y && \
21+
# Then add dependencies
22+
npm install keytar node-pty spdlog native-watchdog @parcel/watcher && \
23+
# Remove any precompiled native modules
24+
find /tmp/node_modules -name "*.node" -exec rm -rf {} \;
25+
26+
# Build keytar native modue
27+
RUN cd /tmp/node_modules/keytar && \
28+
npm run build && \
29+
strip /tmp/node_modules/keytar/build/Release/keytar.node
30+
31+
# Build node-pty native modue
32+
RUN cd /tmp/node_modules/node-pty && \
33+
npm install && \
34+
strip /tmp/node_modules/node-pty/build/Release/pty.node
35+
36+
# Build spdlog native modue
37+
RUN cd /tmp/node_modules/spdlog && \
38+
npm rebuild && \
39+
strip /tmp/node_modules/spdlog/build/Release/spdlog.node
40+
41+
# Build native-watchdog native modue
42+
RUN cd /tmp/node_modules/native-watchdog && \
43+
npm rebuild && \
44+
strip /tmp/node_modules/native-watchdog/build/Release/watchdog.node
45+
46+
# Build @parcel/watcher native modue
47+
RUN cd /tmp/node_modules/@parcel/watcher && \
48+
npm install && \
49+
strip /tmp/node_modules/@parcel/watcher/build/Release/watcher.node
50+
51+
# Download 'cloudflared' manually instead of using apk.
52+
# This is currently required because it is only available on the edge/testing Alpine repo.
53+
RUN wget https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARE_VERSION}/cloudflared-linux-${TARGETARCH} && \
54+
chmod +x cloudflared-linux-${TARGETARCH} && \
55+
# Remove debug symbols
56+
strip cloudflared-linux-${TARGETARCH} && \
57+
# Put it into a 'staging' folder
58+
mkdir -p /tmp/staging/usr/bin && \
59+
mv cloudflared-linux-${TARGETARCH} /tmp/staging/usr/bin/cloudflared && \
60+
sudo chown root:root /tmp/staging/usr/bin/cloudflared
61+
62+
# Download 'openvscode-server'
63+
RUN wget https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v1.71.0/openvscode-server-${OPENVSCODE_VERSION}-linux-${ALT_ARCH}.tar.gz && \
64+
# Unpack it
65+
tar -xf openvscode-server-${OPENVSCODE_VERSION}-linux-${ALT_ARCH}.tar.gz && \
66+
rm openvscode-server-${OPENVSCODE_VERSION}-linux-${ALT_ARCH}.tar.gz && \
67+
# Remove the 'node binary that comes with it
68+
rm openvscode-server-${OPENVSCODE_VERSION}-linux-${ALT_ARCH}/node && \
69+
# Replacing it with a symlink
70+
ln -s /usr/bin/node ./openvscode-server-v1.71.0-linux-${ALT_ARCH}/node && \
71+
# Remove pre-compiled binary node modules
72+
find . -name "*.node" -exec rm -rf {} \; && \
73+
# Put everything into a 'staging' folder
74+
sudo mkdir -p /tmp/staging/opt/ && \
75+
sudo mv openvscode-server-${OPENVSCODE_VERSION}-linux-${ALT_ARCH} /tmp/staging/opt/openvscode-server && \
76+
sudo cp /tmp/node_modules/keytar/build/Release/keytar.node /tmp/staging/opt/openvscode-server/node_modules/keytar/build/Release/keytar.node && \
77+
sudo cp /tmp/node_modules/node-pty/build/Release/pty.node /tmp/staging/opt/openvscode-server/node_modules/node-pty/build/Release/pty.node && \
78+
sudo cp /tmp/node_modules/spdlog/build/Release/spdlog.node /tmp/staging/opt/openvscode-server/node_modules/spdlog/build/Release/spdlog.node && \
79+
sudo cp /tmp/node_modules/native-watchdog/build/Release/watchdog.node /tmp/staging/opt/openvscode-server/node_modules/native-watchdog/build/Release/watchdog.node && \
80+
sudo cp /tmp/node_modules/@parcel/watcher/build/Release/watcher.node /tmp/staging/opt/openvscode-server/node_modules/@parcel/watcher/build/Release/watcher.node && \
81+
sudo chown -R root:root /tmp/staging/opt/openvscode-server
82+
83+
# This inherits from the hack above
84+
FROM ${TARGETOS}-${TARGETARCH} AS final
85+
ARG TARGETARCH
86+
87+
# Copy stuff from the staging folder of the 'builder' stage
88+
COPY --from=builder /tmp/staging /
89+
90+
ENV PATH=$PATH:/opt/openvscode-server/bin
91+
EXPOSE 8000
92+
CMD ["openvscode-server", "serve-local", "--host", "0.0.0.0", "--port", "8000", "--accept-server-license-terms", "--disable-telemetry", "--without-connection-token"]

0 commit comments

Comments
 (0)