Skip to content

Commit

Permalink
Fixed docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
aldwin7894 committed Aug 17, 2022
1 parent 385f536 commit 80a6501
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
13 changes: 5 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,10 @@ build-iPhoneSimulator/
# End of https://www.toptal.com/developers/gitignore/api/node,ruby,rails,linux,macos

**/cache
.asset_sync_remote_file_list_cache.json
*dump*
vendor
.git

# Vite Ruby
/public/vite*
# Vite uses dotenv and suggests to ignore local-only env files. See
# https://vitejs.dev/guide/env-and-mode.html#env-files
.github
.vscode
*.local
dump.rdb
Dockerfile
docker-compose.yml
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ ENV NPM_VERSION 8.16.0
ENV YARN_VERSION 1.22.0
ENV BUNDLE_PATH=/gems
ENV PATH="/node-v${NODE_VERSION}-linux-x64/bin:${PATH}"
ENV RAILS_ENV="production"
ENV NODE_ENV="production"
ARG OCCSON_ACCESS_TOKEN_ARG
ARG OCCSON_PASSPHRASE_ARG
ENV OCCSON_ACCESS_TOKEN=$OCCSON_ACCESS_TOKEN_ARG
ENV OCCSON_PASSPHRASE=$OCCSON_PASSPHRASE_ARG

RUN apt-get update -yq \
&& apt-get install -yq --no-install-recommends \
Expand Down Expand Up @@ -33,7 +39,7 @@ WORKDIR /app
RUN chmod -R 755 ./bin/* \
&& chmod -R 755 ./build.sh \
&& chmod -R 755 ./release-tasks.sh\
&& bash -v ./build.sh "${RAILS_ENV}" "${NODE_ENV}"
&& bash ./build.sh

CMD ["bin/rails", "s", "-b", "0.0.0.0"]
EXPOSE 3000
9 changes: 6 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/usr/bin/env bash
# exit on error
set -e
set -x

yarn install --silent --frozen-lockfile
yarn install --frozen-lockfile

if [[ $RAILS_ENV == "production" ]]; then
BUNDLE_WITHOUT='development:test' BUNDLE_DEPLOYMENT=1 bin/bundle install -j4 --quiet
bin/bundle config set --local without "development test"
bin/bundle config set --local deployment true
bin/bundle install -j4

echo "Precompiling Assets..."
bin/rails assets:precompile
Expand All @@ -18,7 +21,7 @@ if [[ $RAILS_ENV == "production" ]]; then

bash ./release-tasks.sh
else
bin/bundle install --quiet
bin/bundle install
fi

if [ -f tmp/pids/server.pid ]; then
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Application < Rails::Application

document = Occson::Document.new(source, access_token, passphrase).download

document.split("\n").each do |line|
document&.split("\n")&.each do |line|
key, value = line.split("=", 2)

ENV.store(key, value)
Expand Down
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ services:
volumes:
- 'redis:/data'
web:
build: .
build:
context: .
dockerfile: Dockerfile
args:
- "OCCSON_ACCESS_TOKEN_ARG=${OCCSON_ACCESS_TOKEN}"
- "OCCSON_PASSPHRASE_ARG=${OCCSON_PASSPHRASE}"
container_name: aldwin7894
image: aldwin7894/aldwin7894:prod
restart: always
Expand Down

0 comments on commit 80a6501

Please sign in to comment.