Try fix codespaces and simplify devcontainer setup

This commit is contained in:
Matthias 2020-11-09 19:23:49 +01:00 committed by GitHub
parent 1b9fc4704b
commit d3f4dbf3bf
4 changed files with 31 additions and 97 deletions

View File

@ -1,58 +1,19 @@
FROM node:16-slim as dev
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-16-buster
ENV DEBIAN_FRONTEND=noninteractive
ARG USERNAME=node
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
# utils
&& apt-get -y install git procps lsb-release \
# manage dev user
&& usermod -u 1001 node \
#&& groupadd --gid $USER_GID $USERNAME \
&& useradd -m -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
# clean
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
RUN yarn global add @vue/cli
USER $USERNAME
RUN yarn global add @vue/cli \
&& sudo apt-get update \
&& sudo apt-get install -y vim \
&& sudo apt-get clean
ENV HOME /home/$USERNAME
RUN mkdir -p $HOME/frequi/node_modules
WORKDIR $HOME/frequi
COPY ./package.json .
# install dependencies
RUN yarn install
# load ssh key in bash terminal
RUN mkdir -p ${HOME}/commandhistory \
# && echo "eval \$(ssh-agent) && ssh-add ~/.ssh/id_rsa" >> ${HOME}/.bashrc \
# set variable bash history
&& echo "export PROMPT_COMMAND='history -a'" >> ${HOME}/.bashrc \
&& echo "export HISTFILE=~/commandhistory/.bash_history" >> ${HOME}/.bashrc
EXPOSE 8080
FROM dev as vscode
WORKDIR $HOME
# load ssh key in bash terminal
RUN echo "eval \$(ssh-agent) && ssh-add ~/.ssh/id_rsa" >> .bashrc
# set variable bash history
RUN echo "export PROMPT_COMMAND='history -a'" >> .bashrc \
&& echo "export HISTFILE=~/commandhistory/.bash_history" >> .bashrc
# ensure folder owned by $USERNAME
RUN mkdir -p .vscode-server .vscode-server-insiders commandhistory
ENV DEBIAN_FRONTEND=

View File

@ -1,15 +1,26 @@
/* cSpell:disable */
{
"name": "frequi",
"dockerComposeFile": ["docker-compose.yml","docker-compose.vscode.yml"],
"service": "web",
"workspaceFolder": "/home/dev/frequi",
"build": {
"dockerfile": "Dockerfile"
},
"forwardPorts": [
8080
],
"mounts": [
"source=frequi-bashhistory,target=/home/node/commandhistory,type=volume"
],
"remoteUser": "node",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
// "editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"emmet.includeLanguages": {
"vue": "html",
"vue-html": "html"
}
},
"workbench.iconTheme": "vscode-icons",
},
"extensions": [
"octref.vetur",
@ -17,5 +28,7 @@
"yzhang.markdown-all-in-one",
"marquesmps.dockerfile-validator",
"streetsidesoftware.code-spell-checker",
]
"vscode-icons-team.vscode-icons",
],
"postCreateCommand": "yarn install",
}

View File

@ -1,17 +0,0 @@
version: '3.4'
services:
web:
build:
target: vscode
image: freqtradeorg/frequi:vscode
volumes:
- "/home/${USER}/.ssh:/home/dev/.ssh:ro"
- "/home/${USER}/.gitconfig:/home/dev/.gitconfig:ro"
- frequi-bashhistory:/home/dev/commandhistory
- frequi-vscode-server:/home/dev/.vscode-server
- frequi-server-insiders:/home/dev/.vscode-server-insiders
volumes:
frequi-bashhistory:
frequi-vscode-server:
frequi-server-insiders:

View File

@ -1,23 +0,0 @@
version: '3.4'
services:
web:
build:
context: ..
target: dev
dockerfile: .devcontainer/Dockerfile
image: freqtradeorg/frequi:dev
user: dev
volumes:
- ../:/home/dev/frequi
- frequi-node-modules:/home/dev/frequi/node_modules
command: /bin/sh -c "while sleep 1000; do :; done"
networks:
- frequi
ports:
- 8080:8080
networks:
frequi:
volumes:
frequi-node-modules: