Git Product home page Git Product logo

spree_docker_template's Introduction

Spree Docker Template

This repository contains a basic Dockerfile and Docker Compose templates for running Spree-based applications.

The Dockerfile is based on latest Ruby image, it also installs required dependencies for the application (Yarn, PostgreSQL libraries, ImageMagick).

Included Docker Compose creates a two containers that can be used in development or test deployments: one for Spree and one for PostgreSQL.

Setup

1. Move the contents of this repository to the root of your project

2. Configure database access

By default, the hostname of the database is postgres and the port is 5432. To make your Rails application connect with it you can:

  • use the DATABASE_URL environment variable through envvars defined in the .env file

3. Build the images:

$ docker-compose build

The version of the bundler included in the alpine image (1.17.2) may be different than the bundler used in your project. You can find the right version in the BUNDLED_WITH section of your Gemfile.lock.

You can make it use your version by passing it as a build argument when running docker-compose build:

$ docker-compose build --build-arg BUNDLER_VERSION=<YOUR_BUNDLER_VERSION>

or place it directly in the environment of the spree service in docker-compose.yml:

spree:
  build:
    context: .
    args:
      BUNDLER_VERSION: 2.1.2

Since the default compose uses the build: context syntax you need to explicitly add the context path.

The image also uses Ruby 2.6.6 by default. If you need another version for your project you can set it identically to how you set BUNDLER_VERSION:

$ docker-compose build --build-arg RUBY_VERSION=<YOUR_RUBY_VERSION>

or change docker-compose.yml:

spree:
  build:
    context: .
    args:
      RUBY_VERSION: 2.7.0

4. Create the databases

$ docker-compose run spree rails db:create

5. Load the schema

$ docker-compose run spree rails db:schema:load

6. Seed the database

$ docker-compose run spree rails db:seed

7. Precompiling assets If you wish to precompile assets you can do so by running:

$ docker-compose run spree rails assets:precompile

Running the application

To run the application simply execute:

$ docker-compose up

You should now be able to visit http://localhost:3000 in your browser.

spree_docker_template's People

Contributors

kshalot avatar rafalcymerys avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

hungom

spree_docker_template's Issues

Pass database config via URL

There's a DATABASE_URL env variable we can pass to Spree (e.g. in docker-compose), instead of having to create database.yml file

Add RAILS_ENV env variable

It would be great to have it set explicitly in docker-compose, so that when using the template we won't forget to set it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.