-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayerfile
57 lines (42 loc) · 1.8 KB
/
Layerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#This is an example webapp.io configuration for rails!
FROM vm/ubuntu:18.04
# To note: Layerfiles create entire VMs, *not* containers!
# Install postgresql and run it in the background
RUN apt-get update && \
apt-get install postgresql postgresql-contrib libpq-dev
# install rails dependencies
RUN curl -fSsL https://deb.nodesource.com/setup_12.x | bash && \
curl -fSsL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install git-core zlib1g-dev build-essential libssl-dev \
libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev \
libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv
ENV PATH=$HOME/.rbenv/bin:$PATH
RUN echo 'eval "$(rbenv init -)"' >> ~/.bashrc
RUN git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
RUN echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
RUN rbenv install 2.7.1
ENV PATH=$HOME/.rbenv/versions/2.7.1/bin:$PATH
RUN gem install pg rails
ENV RAILS_ENV=development
RUN sudo -u postgres createuser -s -i -d -r -l -w root
RUN sudo -u postgres -H -- psql -t -c "CREATE DATABASE mydb;"
RUN sudo -u postgres -H -- psql -c "ALTER ROLE root WITH PASSWORD 'password';"
# Copy your rails app into the runner
COPY . .
# set up database
RUN echo -e 'development:\n\
adapter: postgresql\n\
encoder: unicode\n\
database: mydb\n\
username: root\n\
password: password\n' > config/database.yml
# run migrations
RUN bundle install
RUN bundle exec rake db:migrate
RUN bundle exec rake db:setup
# Start the server
RUN BACKGROUND rails server --binding 0.0.0.0
EXPOSE WEBSITE localhost:3000