-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
81 additions
and
46 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,7 @@ yarn-debug.log* | |
|
||
/app/assets/builds/* | ||
!/app/assets/builds/.keep | ||
|
||
# Ignore VIM swapfiles | ||
*.swo | ||
*.swp |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,50 @@ | ||
# syntax = docker/dockerfile:1.3 | ||
FROM ruby:2.7.4 AS builder | ||
|
||
# set env vars | ||
ENV APP_HOME /home/app/MyLibraryNYCApp | ||
ENV AWS_DEFAULT_REGION=us-east-1 | ||
|
||
ARG RAILS_ENV | ||
ENV RAILS_ENV=${RAILS_ENV} | ||
|
||
# Set base image and working directory | ||
FROM ruby:2.7.4 | ||
|
||
# Install necessary packages, including curl and PostgreSQL client | ||
RUN apt-get update -qq && apt-get install -y \ | ||
curl \ | ||
postgresql-client \ | ||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ | ||
&& apt-get install -y nodejs \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Yarn globally | ||
RUN npm install -g yarn | ||
|
||
# Set environment variables | ||
ENV RAILS_ENV=development | ||
ENV APP_HOME=/app | ||
RUN mkdir $APP_HOME | ||
WORKDIR $APP_HOME | ||
|
||
# install packages | ||
RUN apt-get update -qq \ | ||
&& apt-get install -y \ | ||
curl \ | ||
postgresql-client \ | ||
git | ||
|
||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - \ | ||
&& apt-get -y install nodejs \ | ||
&& npm install --global yarn | ||
|
||
# Install esbuild | ||
# Install esbuild globally | ||
RUN npm install -g esbuild | ||
|
||
# set up app files | ||
COPY . $APP_HOME | ||
COPY Gemfile $APP_HOME | ||
COPY Gemfile.lock $APP_HOME | ||
WORKDIR $APP_HOME | ||
# Copy Gemfile and Gemfile.lock first | ||
COPY Gemfile Gemfile.lock $APP_HOME/ | ||
|
||
# Install bundler and Ruby dependencies | ||
RUN gem install bundler -v 2.4.22 | ||
RUN bundle install --jobs 30 | ||
|
||
## bundle | ||
ENV BUNDLER_VERSION=2.4.22 | ||
RUN gem install bundler -v $BUNDLER_VERSION | ||
RUN bundle config --global github.https true \ | ||
&& bundle install --jobs 30 | ||
# Copy package.json and package-lock.json before running yarn install | ||
COPY package.json $APP_HOME/ | ||
|
||
COPY package.json $APP_HOME/package.json | ||
COPY package-lock.json $APP_HOME/package-lock.json | ||
# Install JS dependencies | ||
RUN yarn install | ||
|
||
# build | ||
# Now copy the rest of the application | ||
COPY . $APP_HOME/ | ||
|
||
# Precompile assets | ||
RUN yarn build | ||
RUN yarn build:css | ||
RUN --mount=type=secret,id=AWS_ACCESS_KEY_ID \ | ||
--mount=type=secret,id=AWS_SECRET_ACCESS_KEY \ | ||
AWS_ACCESS_KEY_ID=$(cat /run/secrets/AWS_ACCESS_KEY_ID) \ | ||
&& export AWS_ACCESS_KEY_ID \ | ||
AWS_SECRET_ACCESS_KEY=$(cat /run/secrets/AWS_SECRET_ACCESS_KEY) \ | ||
&& export AWS_SECRET_ACCESS_KEY \ | ||
&& bundle exe rails assets:precompile | ||
|
||
# Expose the app port | ||
EXPOSE 3000 | ||
|
||
# Start the server | ||
CMD ["bundle", "exec", "rails", "server", "-p", "3000", "-b", "0.0.0.0"] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
services: | ||
web: | ||
build: | ||
context: . | ||
ports: | ||
- "3000:3000" | ||
environment: | ||
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} | ||
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} | ||
- RAILS_ENV=development | ||
volumes: | ||
- .:/app | ||
depends_on: | ||
- db | ||
- elasticsearch | ||
command: ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"] | ||
|
||
db: | ||
image: postgres:13 | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
volumes: | ||
- pgdata:/var/lib/postgresql/data | ||
ports: | ||
- "5432:5432" | ||
|
||
elasticsearch: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.0 | ||
environment: | ||
- discovery.type=single-node | ||
ports: | ||
- "9200:9200" | ||
volumes: | ||
- esdata:/usr/share/elasticsearch/data | ||
|
||
volumes: | ||
pgdata: | ||
esdata: | ||
|
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