0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-22 08:40:03 +01:00
posthog/.github/workflows/codespaces.yml

93 lines
3.7 KiB
YAML
Raw Permalink Normal View History

Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
name: GitHub Codespaces image build
# Run only on master branch. We could also build on branch but this seems like
# an optimization that can be done as and when desired. The main use case we're
# handling is creating and working off a branch from master, so it doesn't seem
# like an immediate requirement to have branches as well.
#
# NOTE: the job is setup to also push branch images as well, and using branch
# and master as caching, so if we want to add the optimisation for branches we
# can just remove the master branch restriction.
on:
push:
branches:
- master
pull_request:
types:
- opened
- labeled
- synchronize
jobs:
build:
name: Build Codespaces image
runs-on: ubuntu-latest
# Build on master and PRs with the label 'codespaces-build' only
if: ${{ github.ref == 'refs/heads/master' || contains(github.event.pull_request.labels.*.name, 'codespaces-build') }}
steps:
- uses: actions/checkout@v3
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
with:
fetch-depth: 1
2023-05-23 14:12:16 +02:00
- name: Lowercase GITHUB_REPOSITORY
id: lowercase
run: |
echo "repository=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
# As ghcr.io complains if the image has upper case letters, we use
# this action to ensure we get a lower case version. See
# https://github.com/docker/build-push-action/issues/237#issuecomment-848673650
# for more details
- name: Docker image metadata
id: meta
uses: docker/metadata-action@v5
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
with:
2023-05-23 14:12:16 +02:00
images: ghcr.io/${{ steps.lowercase.outputs.repository }}/codespaces
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
tags: |
type=ref,event=branch
type=raw,value=master
# We also want to use cache-from when building, but we want to also
# include the master tag so we get the master branch image as well.
# This creates a scope similar to the github cache action scoping
- name: Docker cache-from/cache-to metadata
id: meta-for-cache
uses: docker/metadata-action@v5
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
with:
2023-05-23 14:12:16 +02:00
images: ghcr.io/${{ steps.lowercase.outputs.repository }}/codespaces
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
tags: |
type=raw,value=master
# Install QEMU so we can target x86_64 (github codespaces)
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: .devcontainer/Dockerfile
push: true
platforms: x86_64
# Cache from this branch, or master
cache-from: ${{ steps.meta-for-cache.outputs.tags }}
# NOTE: we use inline as suggested here:
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#inline-cache
# It notes that it doesn't support mode=max, but we're not
# removing any layers, soooo, maybe it's fine.
cache-to: type=inline
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}