Skip to content

Instantly share code, notes, and snippets.

@dalenguyen
Last active October 12, 2018 20:06
Show Gist options
  • Save dalenguyen/be47d51153284035b32ebdaebb4cc191 to your computer and use it in GitHub Desktop.
Save dalenguyen/be47d51153284035b32ebdaebb4cc191 to your computer and use it in GitHub Desktop.

Revisions

  1. Dale Nguyen revised this gist Oct 12, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Dockerfile_NODE
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,8 @@ COPY . .
    # Bower for install old packages - you may not need it
    # Change root password to Docker!@
    # Add user name admin to run command without root
    # If you don't want to add custom user, just use the default node user:
    # USER node instead of USER admin
    # Change folders' owner to admin
    RUN apt-get update \
    && apt-get install sudo -y \
  2. Dale Nguyen created this gist Oct 10, 2018.
    39 changes: 39 additions & 0 deletions Dockerfile_NODE
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    # I'm using NODE 6, you can change to NODE 8 or 10
    FROM node:6

    # This will be the current working dir
    WORKDIR /usr/src/app

    # I copy entire project to the working dir
    COPY . .

    # Root commands
    # Install sudo, vim to make changes for your project files
    # Bower for install old packages - you may not need it
    # Change root password to Docker!@
    # Add user name admin to run command without root
    # Change folders' owner to admin
    RUN apt-get update \
    && apt-get install sudo -y \
    && apt-get install vim -y \
    && npm install -g bower \
    && mkdir /home/admin \
    && echo "root:Docker!@" | chpasswd \
    && useradd admin && echo "admin:admin" | chpasswd && adduser admin sudo \
    && chown -R admin:admin /home/admin \
    && chown -R admin:admin /usr/src/app

    # Run project under user admin
    USER admin

    # Install bower packages
    RUN bower install

    # Install node packages
    RUN npm install

    # Open port for communication
    EXPOSE 3000

    # This will run the project when starts a container
    CMD ./node_modules/gulp/bin/gulp.js serve