Hi i have created rails application(rails new railsapp). My docker file is
# Dockerfile
FROM ruby:2.7.0-alpine as builder
# Install dependencies for native extensions
RUN apk add --no-cache build-base libffi-dev
RUN apk add --no-cache sqlite-libs
RUN apk add --no-cache tzdata sqlite-dev
# This will be our application rootfolder
WORKDIR /application
# Copy all the content from current directory
COPY . /application
COPY Gemfile Gemfile.lock ./
# Build our application
RUN bundle install
RUN bundle exec rake
# Here we start a new stage
FROM nginx:latest
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /application/public /usr/share/nginx/html
I have built image by runnning docker image build -t railsapp . When i run ,
docker container run -p 8888:80 railsapp
I get "welcome nginx page". I should get rails page.. But not displaying. I don't know what mistake I have made in docker file. I'm newbie to the docker. please someone help me. Thanks in advance.
nginx.conf
server {
listen 80;
server_name localhost;
location / {
// i don't know what to specify in the following directives. I have written the following code for react application.
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Try to delete default nginx html file, or create your own nginx config file and specify path to your files
root /var/www/UI;
try_files $uri $uri/ /index.html$is_args$args;