Skip to content

Instantly share code, notes, and snippets.

@PercyODI
Last active September 27, 2021 01:33
Show Gist options
  • Save PercyODI/cd2034e59c5de234c3baabf489536522 to your computer and use it in GitHub Desktop.
Save PercyODI/cd2034e59c5de234c3baabf489536522 to your computer and use it in GitHub Desktop.

Revisions

  1. PercyODI revised this gist Sep 27, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ Build and run development container:
    ```console
    sudo podman build -t devenv:latest -f ./.devenv/Dockerfile --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) .

    sudo podman run -dit -p 2278:22 -v ./:/usr/dev:z --name devenv --user $UID devenv:latest
    sudo podman run -dit -p 2278:22 -v ./:/usr/dev --name devenv devenv:latest
    ```

    Then connect using Visual Studo Code
  2. PercyODI created this gist Sep 27, 2021.
    24 changes: 24 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    FROM ubuntu:bionic

    ARG USER_ID=1000
    ARG GROUP_ID=1000

    RUN apt update -y \
    && apt install openssh-server sudo curl -y

    # Download and install Go
    WORKDIR /tmp
    RUN curl -O https://dl.google.com/go/go1.17.1.linux-amd64.tar.gz
    RUN tar -C /usr/local -xvzf go1.17.1.linux-amd64.tar.gz
    RUN PATH=$PATH:/usr/local/go/bin \
    && echo "export PATH=$PATH" > /etc/environment

    # Create dev user and src directory
    RUN groupadd -g ${GROUP_ID} devgroup
    RUN useradd -l -u ${USER_ID} --create-home -s /bin/bash -g devgroup -G sudo dev
    RUN echo 'dev:dev' | chpasswd

    # Start SSH Service
    EXPOSE 22
    RUN service ssh start
    CMD ["/usr/sbin/sshd","-D"]
    25 changes: 25 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # Dev Environment Testing

    This is for building a development environment using Podman in WSL2 and connecting it with VS Code. This particular dev environment installs Go.
    Could be generalized, and used as a base image for more specific dev environments.

    ## Setup

    Build and run development container:

    ```console
    sudo podman build -t devenv:latest -f ./.devenv/Dockerfile --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) .

    sudo podman run -dit -p 2278:22 -v ./:/usr/dev:z --name devenv --user $UID devenv:latest
    ```

    Then connect using Visual Studo Code

    Remote-SSH: Connect to Host
    Configure new host

    ssh dev@localhost -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 2278 devcontainer

    ## Resources

    - https://jtreminio.com/blog/running-docker-containers-as-current-host-user/