Last active
April 26, 2018 00:11
-
-
Save LeKovr/549bbbb7a0e20cac7aeae2c33be2c3ea to your computer and use it in GitHub Desktop.
Bootstrapping vue.js project with docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bootstrapping vue.js project with docker | |
# Requires: make, docker | |
# Copyright: Aleksei Kovrizhkin <lekovr@gmail.com> | |
# License: MIT | |
# | |
# Place this file into empty dir and run | |
# make simple | |
# (be ready to answer questions about your new project) | |
# | |
# After complete you can run your sample project in development mode: | |
# make dev | |
# and open your browser with URL http://localhost:8080/ | |
SHELL = /bin/bash | |
# Docker image we will use | |
NODE_IMAGE ?= vuejs/ci:latest | |
.PHONY: all help sample dev docker-run npm-install-vue-cli init-webpack-simple npm-install docker-prep-simple npm-run-dev | |
# list targets by default | |
all: help | |
# ------------------------------------------------------------------------------ | |
# Meta targets | |
## setup sample vue.js project in current dir via webpack-simple (see https://github.com/vuejs-templates/webpack-simple) | |
simple: package.json npm-install-vue-cli init-webpack-simple npm-install docker-prep-simple | |
## start prepared project in devel mode | |
dev: npm-run-dev | |
# ------------------------------------------------------------------------------ | |
# Internal targets | |
## npm install vue-cli | |
npm-install-vue-cli: CMD=npm install vue-cli | |
npm-install-vue-cli: docker-run | |
## vue init webpack-simple (You will be asked some questions here) | |
init-webpack-simple: CMD=vue init webpack-simple | |
init-webpack-simple: docker-run1 | |
## npm install | |
npm-install: CMD=npm install | |
npm-install: docker-run2 | |
## npm run dev | |
npm-run-dev: CMD=npm run dev | |
npm-run-dev: docker-run | |
## modify package.json from webpack-simple for docker | |
docker-prep-simple: | |
sed -i 's/webpack-dev-server --open/webpack-dev-server --host 0.0.0.0/' package.json | |
## run docker with command from CMD var (ex: make docker-run CMD="npm run dev") | |
docker-run docker-run1 docker-run2: | |
docker run -ti --rm -p 8080:8080 \ | |
-v $(PWD):/src -w /src \ | |
--env PATH=/src/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ | |
$(NODE_IMAGE) $(CMD) | |
# node will use node_modules from current dir if this file exists | |
package.json: | |
echo '{}' > $@ | |
## List Makefile targets | |
help: | |
@grep -A 1 "^##" Makefile | less | |
## | |
## Press 'q' for exit | |
## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment