-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from ifad/feature/docker
Add Docker support for local development
- Loading branch information
Showing
6 changed files
with
191 additions
and
0 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 |
---|---|---|
|
@@ -7,3 +7,6 @@ tmp/* | |
spec/output.log | ||
.byebug_history | ||
storage/ | ||
|
||
# Docker | ||
docker/colore/variables.env |
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
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,58 @@ | ||
services: | ||
colore: | ||
platform: linux/amd64 | ||
build: | ||
context: . | ||
dockerfile: ./docker/colore/Dockerfile | ||
args: | ||
RACK_ENV: development | ||
container_name: colore | ||
depends_on: | ||
- redis | ||
- sidekiq | ||
env_file: | ||
- ./docker/colore/variables.env | ||
environment: | ||
RACK_ENV: development | ||
networks: | ||
- colore | ||
ports: | ||
- 9240:9240 | ||
restart: on-failure | ||
volumes: | ||
- storage:/colore/storage | ||
redis: | ||
container_name: redis | ||
image: redis:5.0-alpine | ||
networks: | ||
- colore | ||
restart: on-failure | ||
volumes: | ||
- redis:/data | ||
sidekiq: | ||
platform: linux/amd64 | ||
build: | ||
context: . | ||
dockerfile: ./docker/colore/Dockerfile | ||
args: | ||
RACK_ENV: development | ||
command: bundle exec sidekiq -C config/sidekiq.yml -r ./lib/sidekiq_app.rb | ||
container_name: sidekiq | ||
depends_on: | ||
- redis | ||
env_file: | ||
- ./docker/colore/variables.env | ||
environment: | ||
RACK_ENV: development | ||
networks: | ||
- colore | ||
restart: on-failure | ||
volumes: | ||
- storage:/colore/storage | ||
|
||
volumes: | ||
storage: | ||
redis: | ||
|
||
networks: | ||
colore: |
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,91 @@ | ||
FROM ruby:2.6.10 | ||
|
||
RUN apt update && apt install -y \ | ||
build-essential \ | ||
imagemagick \ | ||
libmagic-dev \ | ||
tesseract-ocr | ||
|
||
# Needed to get the latest libreoffice | ||
# Ref: https://wiki.debian.org/LibreOffice#Using_Debian_backports | ||
RUN echo 'deb http://deb.debian.org/debian bullseye-backports main contrib non-free' >> /etc/apt/sources.list | ||
RUN apt update && apt install -y -t bullseye-backports libreoffice | ||
|
||
# Please keep using version 0.12.3 | ||
# With newer versions of wkhtmltopdf, wkhtmltopdf/wkhtmltopdf#1524 and | ||
# wkhtmltopdf/wkhtmltopdf#3241 will affect Colore's PDF output | ||
# TODO: implement PDF comparison specs and update this library | ||
ARG WKHTMLTOPDF_VERSION=0.12.3 | ||
ARG WKHTMLTOPDF_MD5=6e991e1a1f3293ab673afa015703ef86 | ||
|
||
RUN wget --quiet https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/${WKHTMLTOPDF_VERSION}/wkhtmltox-${WKHTMLTOPDF_VERSION}_linux-generic-amd64.tar.xz -O wkhtmltox.tar.xz && \ | ||
echo "${WKHTMLTOPDF_MD5} wkhtmltox.tar.xz" > MD5SUMS && \ | ||
md5sum -c MD5SUMS && \ | ||
tar -xf wkhtmltox.tar.xz && \ | ||
mv wkhtmltox/bin/wkhtmltopdf /usr/local/bin && \ | ||
rm -rf wkhtmltox wkhtmltox.tar.xz MD5SUMS | ||
|
||
ARG TIKA_VERSION=2.9.2 | ||
|
||
RUN wget --quiet https://archive.apache.org/dist/tika/KEYS -O tika-keys && \ | ||
wget --quiet https://archive.apache.org/dist/tika/${TIKA_VERSION}/tika-app-${TIKA_VERSION}.jar.asc -O tika-app.jar.asc && \ | ||
wget --quiet https://archive.apache.org/dist/tika/${TIKA_VERSION}/tika-app-${TIKA_VERSION}.jar -O tika-app.jar && \ | ||
gpg --import tika-keys && \ | ||
gpg --verify tika-app.jar.asc tika-app.jar && \ | ||
rm -f tika-app.jar.asc tika-keys && \ | ||
mv tika-app.jar /usr/share/java/tika-app.jar && \ | ||
echo '#!/bin/sh\n\nARGS="$@"\n\n[ $# -eq 0 ] && ARGS="--help"\n\nexec java -jar /usr/share/java/tika-app.jar $ARGS\n' > /usr/local/bin/tika && \ | ||
chmod +x /usr/local/bin/tika | ||
|
||
ENV APP_DIR /colore | ||
|
||
EXPOSE 9240 | ||
|
||
WORKDIR $APP_DIR | ||
|
||
# Create application user and add permissions | ||
RUN groupadd --gid 1000 colore && \ | ||
useradd --uid 1000 --gid colore --shell /bin/bash --create-home colore && \ | ||
chown -R colore:colore $APP_DIR && \ | ||
chmod -R 755 $APP_DIR | ||
|
||
# Switch to application user | ||
USER colore | ||
|
||
RUN mkdir -p log | ||
RUN mkdir -p tmp/pids | ||
|
||
ARG RACK_ENV | ||
ENV RACK_ENV=${RACK_ENV:-production} | ||
|
||
RUN gem install bundler -v 2.4.22 | ||
|
||
# Copy command always runs as root | ||
COPY --chown=colore:colore Gemfile . | ||
COPY --chown=colore:colore Gemfile.lock . | ||
|
||
RUN echo $RACK_ENV | ||
RUN \ | ||
if [ "$RACK_ENV" = "development" ] || [ "$RACK_ENV" = "test" ]; then \ | ||
bundle install --retry 10; \ | ||
else \ | ||
bundle config set deployment 'true' && bundle --retry 10; \ | ||
fi | ||
|
||
COPY --chown=colore:colore bin ./bin | ||
COPY --chown=colore:colore config ./config | ||
COPY --chown=colore:colore lib ./lib | ||
COPY --chown=colore:colore spec ./spec | ||
COPY --chown=colore:colore config.ru . | ||
COPY --chown=colore:colore Rakefile . | ||
COPY --chown=colore:colore unicorn.rb . | ||
|
||
# Create the shared volume so it will be owned by the application user | ||
RUN mkdir -p storage | ||
|
||
COPY --chown=colore:colore docker/colore/docker-entrypoint.sh ./bin | ||
RUN chmod +x ./bin/docker-entrypoint.sh | ||
|
||
ENTRYPOINT ["/colore/bin/docker-entrypoint.sh"] | ||
|
||
CMD ["bundle", "exec", "unicorn"] |
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,8 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
pwd | ||
|
||
rm -f tmp/pids/*.pid | ||
|
||
exec "$@" |
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,4 @@ | ||
LANG=en_US.UTF-8 | ||
LANGUAGE=en_US.UTF-8 | ||
LC_ALL=C.UTF-8 | ||
REDIS_URL=redis://redis:6379/4 |