Introduces openSUSE based docker-compose environment
This commit is contained in:
parent
824d83411d
commit
8fd3004d7f
7 changed files with 126 additions and 50 deletions
64
Dockerfile
64
Dockerfile
|
|
@ -1,58 +1,22 @@
|
|||
FROM ruby:2.3
|
||||
FROM osem/base
|
||||
ARG CONTAINER_USERID
|
||||
|
||||
MAINTAINER TheAssassin <theassassin@users.noreply.github.com>
|
||||
# Configure our user
|
||||
RUN usermod -u $CONTAINER_USERID osem
|
||||
|
||||
# required for compiling assets
|
||||
RUN apt-get update && \
|
||||
apt-get install -y nodejs nodejs-legacy mariadb-client imagemagick
|
||||
|
||||
# used to run the container without root permissions
|
||||
RUN adduser --home /osem/ --system --group --disabled-login --disabled-password osem
|
||||
|
||||
# required to detect when the database is up and running in init.sh
|
||||
RUN cd /usr/bin && \
|
||||
wget https://github.com/jwilder/dockerize/releases/download/v0.3.0/dockerize-linux-amd64-v0.3.0.tar.gz -O dockerize.tar.gz && \
|
||||
echo "36e8319cdf9d2b07340f456ec61cfa0f495ec6c130b02ad9c116fd55a5c43fa1 dockerize.tar.gz" | sha256sum -c && \
|
||||
tar -xf dockerize.tar.gz && \
|
||||
rm dockerize.tar.gz
|
||||
|
||||
# dumb-init for a proper PID 1
|
||||
RUN cd /tmp && \
|
||||
wget https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
|
||||
dpkg -i dumb-init_1.2.0_amd64.deb && \
|
||||
rm dumb-init_1.2.0_amd64.deb
|
||||
|
||||
# explicitly add Gemfile and install dependencies using bundler to make use of
|
||||
# Docker's caching
|
||||
WORKDIR /osem/
|
||||
# We copy the Gemfiles into this intermediate build stage so it's checksum
|
||||
# changes and all the subsequent stages (a.k.a. the bundle install call below)
|
||||
# have to be rebuild. Otherwise, after the first build of this image,
|
||||
# docker would use it's cache for this and the following stages.
|
||||
COPY Gemfile /osem/
|
||||
COPY Gemfile.lock /osem/
|
||||
RUN bundle install --without test development
|
||||
|
||||
# add OSEM files and prepare them for use inside a Docker container
|
||||
COPY . /osem/
|
||||
RUN chown -R osem.root /osem/ && \
|
||||
chmod -R g=u /osem/ && \
|
||||
mv /osem/config/database.yml.docker /osem/config/database.yml
|
||||
|
||||
# data directory is used to cache the secret key in a file
|
||||
ENV DATA_DIR /data
|
||||
RUN install -d -m 0770 -o osem -g root $DATA_DIR
|
||||
# data persistence for uploaded files (logos, other pictures, etc)
|
||||
RUN mkdir 0775 -p /osem/tmp/cache /osem/tmp/uploads/ && \
|
||||
chown -R osem.osem /osem/tmp/
|
||||
VOLUME ["$DATA_DIR", "/osem/tmp/uploads/", "/osem/public/system/"]
|
||||
RUN chown -R osem /osem
|
||||
|
||||
# Add our files
|
||||
USER osem
|
||||
EXPOSE 9292
|
||||
WORKDIR /osem/
|
||||
|
||||
COPY docker/init.sh /init.sh
|
||||
# Install our bundle
|
||||
RUN export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --jobs=3 --retry=3
|
||||
|
||||
# a user could override this if they wanted to serve the static files directly
|
||||
# from a webserver
|
||||
ENV RAILS_SERVE_STATIC_FILES 1
|
||||
|
||||
# Runs "/usr/bin/dumb-init -- /my/script --with --args"
|
||||
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||
|
||||
CMD ["bash", "/init.sh"]
|
||||
CMD ["foreman", "start"]
|
||||
|
|
|
|||
34
Dockerfile.base
Normal file
34
Dockerfile.base
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
FROM opensuse/leap:15
|
||||
|
||||
# Disable repositories we dont need
|
||||
RUN zypper rr openSUSE-Leap-15.0-Non-Oss openSUSE-Leap-15.0-Update-Non-Oss
|
||||
|
||||
# Install our requirements
|
||||
RUN zypper -n install --no-recommends \
|
||||
# for compiling assets/gems
|
||||
nodejs8 gcc-c++ git-core make \
|
||||
# for ...
|
||||
ImageMagick \
|
||||
# for bundler
|
||||
sudo \
|
||||
# as databases
|
||||
libmariadb-devel postgresql-devel sqlite3-devel \
|
||||
# for nokogiri
|
||||
libxml2-devel libxslt-devel \
|
||||
# as ruby
|
||||
ruby2.5-devel
|
||||
|
||||
# Setup sudo
|
||||
RUN echo 'osem ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
|
||||
|
||||
# Disable versioned gem binary names
|
||||
RUN echo 'install: --no-format-executable' >> /etc/gemrc
|
||||
|
||||
# Install bundler & foreman
|
||||
RUN gem install bundler foreman
|
||||
|
||||
# Create our user
|
||||
RUN useradd -m --user-group osem
|
||||
|
||||
CMD ["/bin/bash", "-l"]
|
||||
|
||||
24
Dockerfile.production
Normal file
24
Dockerfile.production
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
FROM osem/base
|
||||
|
||||
# We copy the Gemfiles into this intermediate build stage so it's checksum
|
||||
# changes and all the subsequent stages (a.k.a. the bundle install call below)
|
||||
# have to be rebuild. Otherwise, after the first build of this image,
|
||||
# docker would use it's cache for this and the following stages.
|
||||
COPY Gemfile /osem/
|
||||
COPY Gemfile.lock /osem/
|
||||
RUN chown -R osem /osem
|
||||
|
||||
# Add our files
|
||||
USER osem
|
||||
WORKDIR /osem/
|
||||
COPY --chown=osem:osem . /osem/
|
||||
|
||||
# Install our bundle
|
||||
RUN export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --jobs=3 --retry=3 --without test development
|
||||
|
||||
# Configure OSEM
|
||||
RUN mv config/database.yml.example config/database.yml
|
||||
|
||||
ENV RAILS_ENV=production
|
||||
|
||||
CMD ["foreman", "start"]
|
||||
3
bin/osem-init.sh
Executable file
3
bin/osem-init.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
bundle exec rake setup:bootstrap
|
||||
foreman start
|
||||
7
docker-compose.override.yml.example
Normal file
7
docker-compose.override.yml.example
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# This file is generated by our Rakefile. Do not change it!
|
||||
version: '2'
|
||||
services:
|
||||
web:
|
||||
build:
|
||||
args:
|
||||
CONTAINER_USERID: 13042
|
||||
17
docker-compose.yml.dev-example
Normal file
17
docker-compose.yml.dev-example
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
version: "2"
|
||||
|
||||
services:
|
||||
database:
|
||||
image: postgres
|
||||
environment:
|
||||
PGDATA: /var/lib/postgresql/data/pgdata
|
||||
web:
|
||||
build: .
|
||||
# env_file: dotenv.example
|
||||
command: /osem/bin/osem-init.sh
|
||||
depends_on:
|
||||
- database
|
||||
ports:
|
||||
- 5000:5000
|
||||
volumes:
|
||||
- .:/osem
|
||||
27
docker-compose.yml.production-example
Normal file
27
docker-compose.yml.production-example
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
version: "2"
|
||||
|
||||
services:
|
||||
database:
|
||||
image: postgres
|
||||
environment:
|
||||
PGDATA: /var/lib/postgresql/data/pgdata
|
||||
volumes:
|
||||
- database:/var/lib/postgresql/data/pgdata
|
||||
web:
|
||||
build: .
|
||||
dockerfile: Dockerfile.production
|
||||
env_file: .env.production # see dotenv.example file
|
||||
depends_on:
|
||||
- database
|
||||
ports:
|
||||
- 5000:5000
|
||||
volumes:
|
||||
- .:/osem
|
||||
- web-data:/osem/public/system
|
||||
- web-logs:/osem/log
|
||||
|
||||
# named volumes to persist data
|
||||
volumes:
|
||||
database:
|
||||
web-data:
|
||||
web-logs:
|
||||
Loading…
Add table
Add a link
Reference in a new issue