Skip to content

Instantly share code, notes, and snippets.

View alfredorico's full-sized avatar

Alfredo E. Rico Moros alfredorico

View GitHub Profile

Generate a react app with docker and vite

To generate a react app using vite, just run the following command in a shell.

docker run --rm -it --user node  -w /app -v ${PWD}:/app node:18-slim npm create vite

Then you might add the following Dockerfile.dev to the project:

@alfredorico
alfredorico / generate_vue_app_with_docker.md
Created July 24, 2023 20:49
Creating a new Vue app with docker command

In order to generate a new Vue app without any node installation in the host machine we can run the following command:

docker run --rm -v "${PWD}:/app" -w "/app" -it node:18-slim \
bash -c "npm create vue@3 && chown -R $(id -u):$(id -g) ."

Because I'm using Linux, I need to run the "chown" command to change the ownership from root (docker generated files are owned by root) to my local user.

Run the following command to generate a new rails app without any ruby installation in the host machine. it just needs Docker.

export APP_NAME=myapp ; docker run --rm -v ${PWD}:/$APP_NAME -w /$APP_NAME -t ruby:slim \
sh -c "apt update && apt install -y --no-install-recommends git build-essential libpq-dev\
&& gem install -N rails -v '~>7' \
&& rails new $APP_NAME --database=postgresql --skip-system-test --skip-test \
&& chown -R $(id -u):$(id -g) $APP_NAME/"
@alfredorico
alfredorico / rubygem_with_docker.md
Last active October 17, 2023 14:13
Generate a Ruby gem with docker

This is an opinionated gist just to show that it's possible to start a ruby gem development work using Docker (I don't want any ruby installation in my manjaro laptop).

To generate a new gem in linux you can use the following command (if you're using MacOS there is no need to use --user flag):

docker run --rm -it -w /app -v ${PWD}:/app ruby:slim bash -c "bundle gem newgem && chown -R $(id -u):$(id -g) ./newgem" 

Then you can use the following Dockerfile to start the gem development work: