Skip to content

Commit

Permalink
Add VSCode devcontainers (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
skrysmanski authored Jul 25, 2021
1 parent 3b01166 commit 266765b
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 18 deletions.
17 changes: 17 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.185.0/containers/php/.devcontainer/base.Dockerfile

# [Choice] PHP version: 8, 8.0, 7, 7.4, 7.3
ARG VARIANT="7"
FROM mcr.microsoft.com/vscode/devcontainers/php:0-${VARIANT}

# [Option] Install Node.js
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.185.0/containers/php
{
"name": "PHP",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update VARIANT to pick a PHP version: 8, 8.0, 7, 7.4, 7.3
"VARIANT": "7",
"INSTALL_NODE": "true",
"NODE_VERSION": "lts/*"
}
},

// Set *default* container specific settings.json values on container create.
"settings": {
"php.validate.executablePath": "/usr/local/bin/php"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"editorconfig.editorconfig",
"davidanson.vscode-markdownlint",
"streetsidesoftware.code-spell-checker",
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [8080],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "yarn install --cwd=src",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"editorconfig.editorconfig",
"ms-vscode-remote.remote-containers",
]
}
17 changes: 7 additions & 10 deletions HACKING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# How to work on this project

## Local dev env
To run this project locally, you need Docker.
The recommended development workflow is:

Then call:
1. Use **Visual Studio Code** and **Docker Desktop**
1. Install the [Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) (see recommended extension)
1. Open the **Command Palette** and choose **Remote-Containers: Reopen in Container**

```
docker-compose up
```
This will give you a [development Docker container](https://code.visualstudio.com/docs/remote/containers) that contains all necessary tools (PHP, Node, Yarn) and that can be edited directly from within Visual Studio Code.

The site will then be available at:
You can then start a webserver at port 8080 by calling `start-server.sh` via the **integrated terminal** in VSCode.

```
http://localhost:8080
```
To rebuild the container, open the Command Palette and choose **Remote-Containers: Rebuild Container**.
8 changes: 0 additions & 8 deletions docker-compose.yml

This file was deleted.

Binary file removed horz-favicon.ico
Binary file not shown.
Binary file removed me.png
Binary file not shown.
3 changes: 3 additions & 0 deletions src/horz-favicon.ico
Git LFS file not shown
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/me.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/vert-favicon.ico
Git LFS file not shown
File renamed without changes.
3 changes: 3 additions & 0 deletions start-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh -e

php -S 0.0.0.0:8080 -t src
Binary file removed vert-favicon.ico
Binary file not shown.

0 comments on commit 266765b

Please sign in to comment.