Giter Site home page Giter Site logo

node's Introduction

NodeJS

node:alpine with a few missing basics installed:

  • bash
  • curl
  • git
  • jq
  • less
  • openssh-client
  • vim

Probably better off using node:latest, tbh...

Use with VSCode

I typically have something like this in my .devcontainer/

Dockerfile

FROM supastuff/node:14-alpine3.12

ARG USERNAME=node

RUN mkdir -p /home/$USERNAME/workspace/node_modules \
        /home/$USERNAME/.vscode-server/extensions \
        /home/$USERNAME/.vscode-server-insiders/extensions \
 && chown -R $USERNAME \
        /home/$USERNAME/workspace \
        /home/$USERNAME/.vscode-server \
        /home/$USERNAME/.vscode-server-insiders

COPY entrypoint.sh /bin/entrypoint.sh
RUN chmod +x /bin/entrypoint.sh
ENTRYPOINT ["/bin/entrypoint.sh"]

entrypoint.sh

#!/bin/sh
USERNAME=node
set -e

cp -R /tmp/.ssh /home/$USERNAME/.ssh
chmod 700 /home/$USERNAME/.ssh
chmod 600 /home/$USERNAME/.ssh/*
chmod 644 /home/$USERNAME/.ssh/*.pub

exec "$@"

docker-compose.yml

version: "3"
services:
  web:
    user: node

    build:
      context: .
      dockerfile: Dockerfile

    volumes:
      - ..:/home/node/workspace:cached
      - node_modules:/home/node/workspace/node_modules
      - vscode_server:/home/node/.vscode-server/extensions
      - vscode_server_insiders:/home/node/.vscode-server-insiders/extensions
      # Use your ssh keys from within the container... entrypoint.sh will fix the permissions
      - ~/.ssh:/tmp/.ssh:cached,ro
      # In case you load bash with default settings, changing the history file location
      # prevents the history from being truncated. Add this to your .bashrc:
      # HISTFILE=~/.my_bash_history
      # If you end up with a folder on the host, delete it and create a new file, and rebuild the container
      - ~/.my_bash_history:/home/node/.my_bash_history:cached

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

    ports:
      - "3000:3000"
    networks:
      - default

volumes:
  node_modules:
  vscode_server:
  vscode_server_insiders:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.