How can I install gitea on heroku? - heroku

Here is the repository which I'm referring to. It has this
curl -fsSL https://git.coolaj86.com/coolaj86/gitea-installer.sh/raw/branch/master/install.bash | bash command to install gitea server on linux at port 3000. How can make heroku run this command, I tried heroku bash and ran command over there and it failed.

Related

How to install ruby 2.4.0 in Windows 10

I have ROR projects that need different versions of ruby and one of them need ruby 2.4.0. with Postgresql. I’m using a PC with Windows 10.
How can I install more than one ruby version like in Linux with rvm? and where can I download the Ruby 2.4.0 for Windows? (I saw that rubyinstaller.org doesn’t have this version)
Windows 10 comes with a new feature called Windows Subsystem for Linux (WSL) that allows you to use Bash with the most common Linux tools included the ones you need to install a Ruby Manager Version.
For this tutorial we'll set up Ubuntu on Windows, Ruby 2.4.0, Rails 5.0.1 and PostgreSQL.
Installing Bash On Windows
First enable developer mode on your machine
https://www.youtube.com/watch?v=S6NvjvL3xaI
Next install Windows Subsystem for Linux
https://www.youtube.com/watch?v=g_5hxfFKDL8
And restart your computer.
After the computer reboot open a Command Prompt (CMD) and type
> bash
You will see the next message
This will install Ubuntu on Windows, distributed by Canonical
and licensed under its terms available here:
https://aka.ms/uowterms
Press "y" to continue: y
Press "Y" to continue
Downloading from the Windows Store... 100%
Extracting filesystem, this will take a few minutes….
Bash will ask you for a user, please remember this user because bash will ask you every time you need root permissions in Bash. Also when you time your password you won’t see the keystrokes, it’s normal, only keep typing and press ENTER when you finish.
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms.wslusers
Enter new UNIX username:
Enter new UNIX password:
And your Bash is ready when you see the CMD its in the
mnt/c/Users/your_username directory.
your_username#yourmachine:/mnt/c/Users/your_username$
Installing RVM and Ruby
In your bash copy this line:
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Then install gnup2
$ sudo apt-get install gnupg2
Remember your UNIX password because every time you saw a sudo in the command you will be asked for your password.
Install RVM
$ \curl -sSL https://get.rvm.io -o rvm.sh
$ cat rvm.sh | bash -s stable
$ source ~/.rvm/scripts/rvm
Install Ruby
$ rvm install ruby-2.4.0
If you need to install other version of ruby run this same command like this
$ rvm install ruby-2.3.5
And select the ruby version you want to use
$ rvm --default use 2.3.5
To check if it works
$ ruby -v
Installing RubyOnRails
Install the Ruby’s package manager Bundler
$ gem install bundler
Add NodeJS
$ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
$ sudo apt-get install -y nodejs
Install Rails
$ gem install rails
Installing PostgreSQL
Download PostgreSQL installer and follow the instructions of the installation
https://www.openscg.com/bigsql/postgresql/installers.jsp/
The installer will ask you for a user and a password, also keep them in a safe place because you will use it to access to PostgreSQL command line and in database.ymlin your ROR project.
When the installation finish, return to bash and type the next command
$psql -p 5432 -h localhost -U your_postgresql_username
Bash will ask you the PostgreSQL password and if everything works you will have access to the Postgres shell prompt
psql (9.5.6, server 9.6.2)
WARNING: psql major version 9.5, server major version 9.6.
Some psql features might not work.
Type "help" for help.
postgres=#
Type \q to exit the Postgres shell.
Running your Rails app
Open the project in your favorite editor and update the database.yml with the PostgreSQL username and password.
development:
database: your_app_name_development
username: your_postgres_user
password: your_postgres_password
host: localhost
port: 5432
test:
database: your_app_name_test
username: your_postgres_user
password: your_postgres_password
host: localhost
port: 5432
In Bash go to the directory where is your rails project, for example:
$ cd Projects/my_app
To learn more about Bash navigation visit
https://www.pluralsight.com/guides/beginner-linux-navigation-manual
Create your database
$ rake db:create
Run the rails server to make sure everything is working
$ rails s
And go to your browser and visit
$ localhost:3000
Every time you need a Bash, open a Command Prompt and type
>bash -l
For more detail of each of the commands in this tutorial, visit
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-and-set-up-a-local-programming-environment-on-windows-10
https://medium.com/#colinrubbert/installing-ruby-on-rails-in-windows-10-w-bash-postgresql-e48e55954fbf

Errors while trying to use pip on OpenShift

I am getting the following error both when using git and when logging in via rhc and try to install the requirements file:
The directory '/var/lib/openshift/***/.cache/pip/http' or its parent
directory is not owned by the current user and the cache has been disabled.
Please check the permissions and owner of that directory.
If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
I am not trying to install with sudo.
What I am trying to do is:
Log into via rhc and and ssh: rhc ssh 'app'
activate venv: source $OPENSHIFT_PYTHON_DIR/virtenv/bin/activate
pip install -r "$OPENSHIFT_REPO_DIR" requirements.txt
Note that $OPENSHIFT_PYTHON_DIR and $OPENSHIFT_REPO_DIR are the environment variables given by OpenShift to access the relevant folders.
Any ideas? I am on a Python 2.7 cartridge.
Openshift will automatically install your dependencies based on a requirements.txt file. So you shouldn't ssh into your app and do that yourself.
You can find more information about it on the developer center pages. [1]

Install Docker Toolbox on a Mac via command line

I am trying to automate setting up a developer environment on Mac. Part of that setup is installing the Docker Toolbox. I cannot find any documentation on how do to this via command line. How can I automate this installation (must be triggered via command line)?
Update: As pointed out in a commend by Dennis
Docker for Mac now exists, which is an alternative to Docker Toolbox. You can get it via the homebrew cask: brew cask install docker; open /Applications/Docker.app
Deprecation Warning
Docker Toolbox and Docker Machine have both been deprecated. Docker Desktop is the officially recommended replacement.
Original Answer
I found that Docker Toolbox is available via brew/cask
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Cask
brew install caskroom/cask/brew-cask
# Install docker toolbox
brew cask install docker-toolbox
Once Docker Toolbox is installed you can setup your docker environment using the Get started with Docker Machine guide.
# create the docker machine
docker-machine create --driver "virtualbox" myBoxName
# start the docker machine
docker-machine start myBoxName
# this command allows the docker commands to be used in the terminal
eval "$(docker-machine env myBoxName)"
# at this point can run any "docker" or "docker-compose" commands you want
docker-compose up
At the end of this process, add eval "$(docker-machine env myBoxName)" to your .bash_profile or you will get the following error when you open a new shell or terminal.
"Cannot connect to the Docker daemon. Is the docker daemon running on this host?"
If you start the docker container after opening the terminal, you can either run eval "$(docker-machine env myBoxName)" manually, or reload your bash profile (source ~/.bash_profile).
Docker Toolbox is a good option but currently it seems like Docker for Mac/Windows is becoming better and Docker is investing a lot of time polishing the app. I recommend installing Docker mainly for 2 reasons:
It doesn't interfere with Docker-Toolbox
It runs on HyperKit and therefor runs on you own localhost rather than a Docker Machine IP.
The installation is quite simple:
brew cask install docker
To install docker-toolbox you can refer the above post
Homebrew Updates
I can clear up a few things:
brew cask commands were deprecated on 2020-12-01 with the release of Homebrew 2.6.0. Starting then, all brew cask commands succeeded but displayed a warning informing users that the command would soon be disabled. The message also provides the appropriate replacement.
brew cask commands were disabled on 2020-12-21 with the release of Homebrew 2.7.0. Starting then, all brew cask commands failed and displayed a warning informing users that the command is disabled. The message also provides the appropriate replacement.
With the release of Homebrew 2.8.0 (release date TBD), this disable message will be removed.
The alternative to brew cask <command> is to use brew <command>. In many cases, you can add the --cask flag to specify casks only. For example, brew cask install atom is now brew install atom or brew install --cask atom. There are some casks that share a name with formulae (e.g. wireshark) so adding --cask ensures that the cask is installed not the formula.
I'm not much of an ansible user but I'm happy to try and help out if needed. Feel free to point me in the right direction if anything is blocked and could use feedback from the Homebrew side of things.
Now you can run like
brew install --cask docker

Boot2Docker: can't get ports forwarding to work

I'm playing with boot2docker (docker 1.6) on windows 8.1. I wanted to make myself machine container to play with ruby and I want to be able to connect to rails server from my windows host. To start with small steps first I want to connect to my container from my boot2docker VM. I attach my docker file below, it builds without a problem and I can run a container from it. I do it like so:
docker run -it -p 3000:3000 3564860f7afd /bin/bash
Then in this container I say:
cd ~/myapp && bundle exec rails server -d
And to see if everything is working I do:
~/myapp$ sudo apt-get install wget && wget localhost:3000
and I get http 500, which is ok, I just wanted to check if server is running. Then I exit using ctrl+p, ctrl+q. But then on boot2docker machine I do agin
wget localhost:3000
and get
Connecting to localhost:3000 (127.0.0.1:3000)
wget: error getting response: Connection reset by peer
So it seems like port 3000 is not correctly forwarded to boot2docker VM. What have I done wrong? What did I miss? I googled extensively and tried couple of things like explicitly exposing port from dockerfile of or adding -P switch to run, but I always end up the same way - it's not working.
Any help will be greatly appreciated.
UPDATE 02.05.2015
I have also tried things described in comment from Markus W Mahlberg and reponse from VonC. My VM configuration seems to be ok, I also checked in GUI of VirtualBox and it seems fine. Some more info: When I start
boot2docker ssh -vnNTL 3000:localhost:3000
and then open localhost:3000 on my windows host I see in trace logs in boot2docker console, they look like this:
debug1: channel 1: free: direct-tcpip: listening port 3000 for localhost port 3000, connect from 127.0.0.1 port 50512 to 127.0.0.1 port 3000, nchannels 3
Chrome tells me that the response was empty. From checking the logs on container I know that request never got to it.
End of update
Update 03.05.2015
I thing that my problem have not so much to do with boot2docker or docker as with my computer configuration. I've been over my docker/boot2docker configuration so many times, that it is rather unlikely that I've made a mistake there.
Desperately I've reinstalled boot2docker and VirtualBox, still no effects. Any ideas how to debug what can be wrong with my configuration? Only other idea I have is to try doing the same on another machine. But even if this works my original problem is no less annoying.
End of update
Here is my dockerfile:
FROM ubuntu
MAINTAINER anonymous <anonymous#localhost.com>
LABEL Description="Ruby container"
# based on https://gorails.com/setup/ubuntu/14.10
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get -y install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& groupadd anonymous \
&& useradd anonymous -m -g anonymous -g sudo
ENV HOME /home/anonymous
USER anonymous
RUN git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
RUN echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
RUN echo 'eval "$(rbenv init -)"' >> ~/.bashrc
RUN exec $SHELL
RUN git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
RUN echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
RUN exec $SHELL
RUN git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
ENV PATH "$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
RUN rbenv install 2.2.1
RUN rbenv global 2.2.1
ENV PATH "$HOME/.rbenv/shims:$PATH"
RUN echo 'gem: --no-ri --no-rdoc' > ~/.gemrc
RUN gem install bundler
RUN git config --global color.ui true
RUN git config --global user.name "mindriven"
RUN git config --global user.email "3dcreator.pl#gmail.com"
RUN ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa -C "3dcreator.pl#gmail.com"
RUN sudo apt-get -qy install software-properties-common python-software-properties
RUN sudo add-apt-repository ppa:chris-lea/node.js
RUN sudo apt-get -y install nodejs
RUN gem install rails -v 4.2.0
RUN ~/.rbenv/bin/rbenv rehash
RUN rails -v
RUN sudo apt-get -qy install mysql-server mysql-client
RUN sudo apt-get install libmysqlclient-dev
RUN rails new ~/myapp -d mysql
RUN sudo /etc/init.d/mysql start && cd ~/myapp && rake db:create
See Boot2docker workarounds:
You can use VBoxManage.exe commands to open those ports on the boot2docker VM level, in order for your actual VM host to access them.
By default, only the port 2222 is open, for boot2docker ssh to work and open an interactive ssh boot2docker session.
Just make sure VirtualBox is in your PATH.
VBoxManage modifyvm: works when the boot2docker VM isn't started yet, or after a boot2docker stop,
VBoxManage controlvm: works when the boot2docker VM is running, after a boot2docker start.
Let's say your Docker container exposes the port 8000 and you want access it from your other computers on your LAN. You can do it temporarily, using ssh:
Run following command (and keep it open):
$ boot2docker ssh -vnNTL 8000:localhost:8000
or you can set up a permanent VirtualBox NAT Port forwarding:
$ VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port8000,tcp,,8000,,8000";
If the vm is already running, you should run this other command:
$ VBoxManage controlvm "boot2docker-vm" natpf1 "tcp-port8000,tcp,,8000,,8000";
Now you can access your container from your host machine under
localhost:8000
That way, you don't have to mess around with the VirtualBox GUI, selecting the computer called boot2docker-vm from the list on the left, choosing Settings from the Machine menu (or press Command-S on a Mac), selecting the Network icon at the top, and finally clicking the Port Forwarding button.
boot2docker on Windows (and OSX) is running a VirtualBox VM with Linux in it. By default it exposes only the ports necessary to ssh into the VM. You'll need to modify the VM to get it to expose more ports.
Adding ports to the VM is more about configuring VirtualBox and less about boot2docker (it is a property of the VM, not the software running inside it). Please see the VirtualBox documentation for "port forwarding" and other network configuration. https://www.virtualbox.org/manual/ch06.html
Yes you need to open the ports in the Virtualbox machines:
enter image description here

how do you run heroku client commands on travis-ci?

what can i add to my .travis.yml to run heroku client commands?
e.g. before deploy:
$ heroku maintenance:on
$ heroku pgbackups:capture --expire
and after deploy:
$ heroku maintenance:on
i've tried adding those commands to before_deploy in .travis.yml, but it doesn't have access to the heroku cli tool.
bonus points if i can do this on the app level, e.g. do backups on the production branch, but not staging.
I just installed Heroku toolbelt in a build container. That's how it looks in my build:
sudo: required
before_script:
# this install.sh script requires sudo
- wget -qO- https://toolbelt.heroku.com/install.sh | sh
script:
- /usr/local/heroku/bin/heroku restart --app my-heroku-app-name # requires HEROKU_API_KEY env variable
Note: installing Heroku requires sudo privilege (sudo: required) and if you have to access your app - $HEROKU_API_KEY environment variable must be set.
You might be able to everything you need with the Heroku deployment support available on Travis CI.
If you need to do more, you need to install Heroku toolbelt, and figure out how to do what you want.

Resources