Skip to content

Commit

Permalink
feat(docker): create image for gitpod (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
raisedadead committed Sep 11, 2024
1 parent 9ada09d commit dd321bc
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 11 deletions.
38 changes: 27 additions & 11 deletions .github/workflows/docker--ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,44 @@ jobs:
strategy:
fail-fast: false
matrix:
images: [landing]
images:
- landing
- gitpod-fcc

steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
uses: docker/setup-buildx-action@v3

- name: Log in to the GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.images }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.images }}-
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./docker/${{ matrix.images }}
push: true
tags: |
ghcr.io/freecodecamp/${{ matrix.images }}:${{ github.sha }}
ghcr.io/freecodecamp/${{ matrix.images }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Move cache
run: |
cd docker/${{ matrix.images }}
docker build . \
--tag ghcr.io/freecodecamp/${{ matrix.images }}:${{ github.sha }} \
--tag ghcr.io/freecodecamp/${{ matrix.images }}:latest
docker push --all-tags ghcr.io/freecodecamp/${{ matrix.images }}
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
49 changes: 49 additions & 0 deletions docker/gitpod-fcc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM gitpod/workspace-mongodb:latest

LABEL org.opencontainers.image.source=https://github.com/freecodecamp/infra
LABEL org.opencontainers.image.description="A Gitpod image for the freeCodeCamp.org main repo."
LABEL org.opencontainers.image.licenses=BSD-3-Clause

RUN sudo install-packages \
ca-certificates \
fonts-liberation \
libappindicator3-1 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgbm1 \
libgcc1 \
libglib2.0-0 \
libnspr4 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
lsb-release \
wget \
xdg-utils

# from https://www.gitpod.io/docs/introduction/languages/javascript#node-versions
RUN bash -c 'VERSION="20" \
&& source $HOME/.nvm/nvm.sh && nvm install $VERSION \
&& nvm use $VERSION && nvm alias default $VERSION \
&& npm i -g pnpm@9'

RUN echo "nvm use default &>/dev/null" >> ~/.bashrc.d/51-nvm-fix

RUN npx -y puppeteer browsers install chrome

0 comments on commit dd321bc

Please sign in to comment.