adam

adam

I wonder if anyone in the community has started to use Github’s Codespaces for their team’s development?

If so, what is there to learn? If not, what’s the reason?

Thanks

Showing Posts 19 to 10

Nefcairon

Nefcairon

Do you still prefer gitpod, now that it is Ona?

Is anyone using GitHub Codespaces nowadays? I wonder if I should move my dev setup into the cloud.

joddm

joddm

The HTML IntelliSense/autocomplete does not seem to work for HEEx/Elixir files in GitHub Codespaces.

Possibly related to Allow extension to be installed in container or remote · Issue #12 · phoenixframework/vscode-phoenix (github.com)

joddm

joddm

For completeness, here is a working solution:

devcontainer.json

{
    "dockerComposeFile": "docker-compose.yml",
    "workspaceFolder": "/workspaces/plfantasy",
    "service": "plfantasy",
    "shutdownAction": "stopCompose",
    "features": {
        "ghcr.io/devcontainers/features/common-utils:2": {
            "installZsh": "true",
            "username": "vscode",
            "userUid": "1000",
            "userGid": "1000",
            "upgradePackages": "true"
        },
        "ghcr.io/devcontainers/features/git:1": {
            "version": "latest",
            "ppa": "false"
        }
    },
    // Configure tool-specific properties.
    "customizations": {
        // Configure properties specific to VS Code.
        "vscode": {
            // Set *default* container specific settings.json values on container create.
            "settings": {
                "emmet.includeLanguages": {
                    "phoenix-heex": "html"
                },
                "tailwindCSS.includeLanguages": {
                    "elixir": "html",
                    "phoenix-heex": "html"
                }
            },
            "extensions": [
                "jakebecker.elixir-ls",
                "phoenixframework.phoenix",
                "samuel-pordeus.elixir-test",
                "bradlc.vscode-tailwindcss",
                "ms-azuretools.vscode-docker",
                "ms-vscode.azurecli",
                "eamodio.gitlens"
            ]
        }
    },
    // Use 'forwardPorts' to make a list of ports inside the container available locally.
    "forwardPorts": [
        4000,
        4001,
        5432
    ],
    // Use 'postCreateCommand' to run commands after the container is created.
    "postCreateCommand": "mix local.hex --force && mix local.rebar --force && mix archive.install --force hex phx_new",
    // Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
    "remoteUser": "vscode"
}

docker-compose.yml

version: '3'
services:
  plfantasy:
    build:
      context: ..
      dockerfile: .devcontainer/Dockerfile

    volumes:
      - ../..:/workspaces:cached

    # Overrides default command so things don't shut down after the process ends.
    command: sleep infinity

    environment:
      MIX_ENV: dev

    # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
    network_mode: service:db

    # Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
    # (Adding the "ports" property to this file will not forward from a Codespace.)

  db:
    image: postgres:latest
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres
      POSTGRES_PASSWORD: postgres
    volumes:
      - postgres-data:/var/lib/postgresql/data
volumes:
  postgres-data:

Dockerfile

FROM hexpm/elixir:1.15.7-erlang-26.1.2-debian-buster-20231009-slim AS elixir-build

RUN apt-get update && \
  apt-get install -y git && \
  apt-get install -y postgresql-client && \
  apt-get install -y inotify-tools && \
  apt-get install -y curl && \
  apt-get install -y wget && \
  apt-get install -y gnupg2 && \
  apt-get install -y dirmngr && \
  apt-get install -y gpg && \
  apt-get install -y gawk

Note the use of network_mode in docker-compose.yml. I did not need to tweak the IP mapping in config/dev.exs

joddm

joddm

Did you try to edit the config/dev.exs file?

bdubaut

bdubaut

Yes indeed it is

@arcanemachine setting network_mode to "host" did not change anthying, I am still getting a 502 with strict-origin-when-when-cross-origin referer policy.

arcanemachine

arcanemachine

Great suggestion. That actually fixed an issue I had when Dockerizing a dev server a month or two ago.

joddm

joddm

Stupid question, but is the Phoenix server running?
mix phx.server

Edit:
Or you can try to edit the ip-mapping in config/dev.exs from
http: [ip: {127, 0, 0, 1}, port: 4000]
to
http: [ip: {0, 0, 0, 0}, port: 4000]

arcanemachine

arcanemachine

When I’m having trouble with network configuration on Docker, I sometimes use network_mode: "host" in the compose file to bypass Docker’s networking layer. That way, you can figure out if the problem actually is related to your port config, or if the issue is somewhere else.

Unrelated example for demonstration purposes:

compose.yaml

---
services:
  db:
    image: "docker.io/postgres:16"
    restart: "always"
    environment:
      POSTGRES_DB: "${POSTGRES_DB:?}"
      POSTGRES_USER: "${POSTGRES_USER:-postgres}"
      POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-postgres}"
    network_mode: "host"
    volumes:
      - "postgres:/var/lib/postgresql/data"

volumes:
  postgres:
bdubaut

bdubaut

From the web terminal I can run curl http://localhost:4000 without any issues, I can see the log message in the console. This makes me think that the traffic is actually not reaching the container at all, so I’m scratching my head as to what I’ve misconfigured.

bdubaut

bdubaut

Thank you. I have added the quotes, but it does not change anything :thinking:

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
durvia
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes. We’re a small ...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews