Skip to content

Commit

Permalink
Pass the external port to nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
ikapelyukhin committed Jan 29, 2018
1 parent 1d8a0ec commit 5eb9f48
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EXTERNAL_PORT=8080
SCC_USERNAME=
SCC_PASSWORD=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ config/secrets.yml.key
config/secrets.yml.enc
config/rmt.local.yml

.env
21 changes: 18 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
FROM opensuse/amd64:42.3

RUN zypper --non-interactive install --no-recommend timezone \
RUN zypper --non-interactive install --no-recommend timezone wget \
gcc gcc-c++ libffi-devel make git-core zlib-devel libxml2-devel libxslt-devel cron libmariadb-devel \
mariadb-client vim \
ruby2.4 ruby2.4-devel ruby2.4-rubygem-bundler

RUN zypper --non-interactive install -t pattern devel_basis

ENV DOCKERIZE_VERSION v0.6.0
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

RUN bundle config build.nokogiri --use-system-libraries

ENV RAILS_ENV production

COPY . /srv/www/rmt/
WORKDIR /srv/www/rmt/

RUN sed -i 's/#!\/usr\/bin\/env ruby/#!\/usr\/bin\/ruby.ruby2.4/g' /srv/www/rmt/bin/rmt-cli
RUN ln -s /srv/www/rmt/bin/rmt-cli /usr/bin
RUN bundle

RUN printf "database: &database\n\
Expand All @@ -22,8 +30,15 @@ RUN printf "database: &database\n\
database: <%%= ENV['MYSQL_DATABASE'] %%>\n\
database_development:\n\
<<: *database\n\
database: <%%= ENV['MYSQL_DATABASE'] %%>\n" >> config/rmt.local.yml
database: <%%= ENV['MYSQL_DATABASE'] %%>\n\
cli:\n\
user: root\n\
group: root\n\
scc:\n\
username: <%%= ENV['SCC_USERNAME'] %%>\n\
password: <%%= ENV['SCC_PASSWORD'] %%>\n\
" >> config/rmt.local.yml

EXPOSE 4224

CMD bundle exec rails s -b 0.0.0.0 -p 4224
CMD dockerize -wait tcp://$MYSQL_HOST:3306 -timeout 60s true && bundle exec rails s -b 0.0.0.0 -p 4224
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:
environment:
- MYSQL_HOST=db
- SECRET_KEY_BASE=8ea53ad3bc6c03923e376c8bdd85059c1885524947a7efe53d5e9c9d4e39861106ffd6a2ece82b803072ed701e6c960bade91644979e679416c5f255007237ae
- SCC_USERNAME=${SCC_USERNAME}
- SCC_PASSWORD=${SCC_PASSWORD}
volumes:
- ./public:/srv/www/repo/public/
depends_on:
Expand All @@ -31,8 +33,9 @@ services:
image: nginx
volumes:
- ./public:/var/www/
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./nginx/default.conf:/tmp/default.template
ports:
- 8080:80
- "${EXTERNAL_PORT}:80"
depends_on:
- rmt
entrypoint: /bin/bash -c 'cat /tmp/default.template | sed "s/\\\$$server_port/$EXTERNAL_PORT/g" > /etc/nginx/conf.d/default.conf && nginx -g "daemon off;"'

0 comments on commit 5eb9f48

Please sign in to comment.