Skip to content

Commit

Permalink
add devcontainer configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nogajun committed Oct 2, 2022
1 parent eabbb2a commit dd5f683
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM debian:bullseye

LABEL version="0.1"
LABEL maintainer="[email protected]"
LABEL description="sotmjp2022 build environment"

RUN apt-get -y update && apt-get -y full-upgrade && \
apt-get -y --no-install-recommends install locales sudo build-essential git lv ruby ruby-dev bundler zlib1g-dev && \
apt-get -y autoremove && apt-get -y clean && rm -rf /var/lib/apt/lists/*

ARG UID=1000
ARG GID=1000
ARG USER_LOCALE=ja_JP.UTF-8
ARG GEM=/usr/local/gem

RUN sed -i -e "s/^# \(${USER_LOCALE}\)/\1/g" /etc/locale.gen && \
echo "LANG=${USER_LOCALE}" > /etc/default/locale && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=${USER_LOCALE} && \
groupadd -g ${GID} docker && \
useradd -u ${UID} -g ${GID} -s /bin/bash -m docker && \
gpasswd -a docker docker && \
mkdir -p ${GEM} && \
chown ${UID}:${GID} ${GEM}

ENV LANG ${USER_LOCALE}
ENV LANGUAGE ja
ENV GEM_HOME ${GEM}

USER ${UID}
39 changes: 39 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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.245.2/containers/docker-existing-dockerfile
{
"name": "sotmjp2022",
"build": {
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "Dockerfile",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": ".."
},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.live-server",
"michelemelluso.code-beautifier",
"ecmel.vscode-html-css",
"kargware.vscode-extension-jekyll-kw",
"wingrunr21.vscode-ruby",
"davidanson.vscode-markdownlint"
]
}
},

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

// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "apt-get update && apt-get install -y curl",
"postCreateCommand": "export PATH=$PATH:/usr/local/gem && gem update && bundle install",

// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],

// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "docker"
}
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# State of the map Japan 2022 Website

## How to preview website with Docker and Visual studio code

1. Install [Docker Desktop](https://www.docker.com/) or Docker CLI and [Visual studio code](https://code.visualstudio.com/)
2. Install the [Remote development extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) in visual studio code
3. Open sotmjp2022 directory from visual studio code, and select "Reopen in container" in popup dialog
* Other way: Open sotmjp2022 directory and click the Remote window button on the Remote status bar, then select "Reopen in container"
4. Wait a moment for the build environment to be set up in docker
5. Open "new terminal" in visual studio code and enter the following command

```bash
bundle exec jekyll serve
```

0 comments on commit dd5f683

Please sign in to comment.