Created
August 1, 2023 20:22
-
-
Save davidleandro/73ddc23d913194dd833864172465687e to your computer and use it in GitHub Desktop.
Estudologia Docker config
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
version: "3.8" | |
services: | |
web: | |
build: . | |
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" | |
volumes: | |
- .:/estudologia-api | |
ports: | |
- "3000:3000" | |
depends_on: | |
- redis | |
env_file: | |
- .env | |
redis: | |
image: "redis:alpine" |
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
# Base image: | |
FROM ruby:3.1.3 | |
ARG _WORKDIR=/estudologia-api | |
ARG PORT=3000 | |
# Update and install JavaScript Runtime and PostgreSQL dependencies | |
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client | |
# Create a new directory for the application in the container | |
RUN mkdir ${_WORKDIR} | |
# Set our working directory inside the image | |
WORKDIR ${_WORKDIR} | |
# Copy Gemfile and Gemfile.lock to the working directory | |
COPY Gemfile ${_WORKDIR}/Gemfile | |
COPY Gemfile.lock ${_WORKDIR}/Gemfile.lock | |
# Install the app dependencies | |
RUN bundle install | |
# Copy the rest of the application into the working directory | |
COPY . /estudologia-api | |
# Add a script to be executed every time the container starts. | |
COPY entrypoint.sh /usr/bin/ | |
RUN chmod +x /usr/bin/entrypoint.sh | |
ENTRYPOINT ["entrypoint.sh"] | |
# Expose port in the container | |
EXPOSE ${PORT} | |
# Configure the main process to run when running the image | |
CMD ["rails", "server", "-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
#!/bin/bash | |
set -e | |
# Remove a potentially pre-existing server.pid for Rails. | |
rm -f /myapp/tmp/pids/server.pid | |
# Then exec the container's main process (what's set as CMD in the Dockerfile). | |
exec bundle exec rails db:migrate & | |
exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment