init push - laying out the project

This commit is contained in:
Mike Sutton
2022-11-12 02:27:46 +01:00
commit 14e163a1a5
183 changed files with 20069 additions and 0 deletions

59
portal/docker/Dockerfile Executable file
View File

@ -0,0 +1,59 @@
ARG BASE_IMAGE=wizewerx/rr-alpine-base:latest
ARG GEM_CACHE=${BASE_IMAGE}
FROM $GEM_CACHE AS gems-cache
RUN mkdir -p /usr/local/bundle
FROM $BASE_IMAGE as base
WORKDIR /app
FROM base as gems
WORKDIR /app
ENV RAILS_ROOT /app
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_ENV production
ENV BUNDLE_PATH=/usr/local/bundle
RUN apk add --no-cache \
postgresql-dev \
git \
ruby-dev \
&& rm -rf /var/cache/apk/*
COPY --from=gems-cache /usr/local/bundle /usr/local/bundle
COPY Gemfile ./
COPY Gemfile.lock ./
COPY package.json ./
COPY yarn.lock ./
ENV BUNDLE_GIT__WIZEWERX__TECH mike:bd94eefdabc2dcbe0db2a715715751e801fff9e0
RUN bundle config set deployment 'true' && \
bundle install --jobs 30 --retry 5 && \
rm -rf /usr/local/bundle/cache/*.gem && \
find /usr/local/bundle/gems/ -name "*.c" -delete && \
find /usr/local/bundle/gems/ -name "*.o" -delete
FROM base as final
WORKDIR /app
ENV RAILS_ROOT /app
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_ENV production
ENV BUNDLE_PATH=/usr/local/bundle
## Copy app with gems from former build stage
COPY --from=gems /usr/local/bundle /usr/local/bundle
ADD . .
RUN apk add postgresql-client \
imagemagick \
ffmpeg\
curl \
bash \
&& rm -rf /var/cache/apk/* \
&& RAILS_ENV=production SECRET_KEY_BASE=_ bundle exec rake DATABASE_URL=nulldb:db_shim assets:precompile && \
rm -rf spec node_modules tmp/cache
EXPOSE 3000
CMD bundle exec rake db:migrate && VIA_SERVER=true bundle exec rails s
## without cache
# APP=wizewerx/betbeast && TARGET=master && docker build -f ./docker/Dockerfile -t $APP:$TARGET . && docker push $APP:$TARGET
# with cache
# APP=wizewerx/betbeast && TARGET=master && docker build --cache-from $APP:$TARGET -f ./docker/Dockerfile -t $APP:$TARGET . && docker push $APP:$TARGET
# APP=wizewerx/betbeast && TARGET=master docker push $APP:$TARGET

141
portal/docker/docker-compose.yml Executable file
View File

@ -0,0 +1,141 @@
version: '3.7'
services:
app:
image: wizewerx/betbeast:master
command:
- bundle
- exec
- rails
- s
networks:
- default
- routable
configs:
-
source: betbeast
target: /app/.env
logging:
driver: json-file
options:
max-size: 10M
deploy:
labels:
traefik.http.routers.betbeast_app.tls: 'true'
traefik.http.routers.betbeast_app.rule: Host(`betbeast.wizewerx.tech`)
traefik.http.routers.betbeast_app.entrypoints: websecure
traefik.http.services.betbeast_app.loadbalancer.server.port: '3000'
traefik.enable: 'true'
swarmpit.service.deployment.autoredeploy: 'true'
update_config:
delay: 60s
order: start-first
restart_policy:
condition: on-failure
window: 120s
max_attempts: 3
placement:
constraints:
- node.labels.db == 2
cron_sidekiq:
image: wizewerx/betbeast:master
command:
- bundle
- exec
- sidekiq
environment:
RUN_SIDEKIQ_CRON: 'yes'
networks:
- default
configs:
-
source: betbeast
target: /app/.env
logging:
driver: json-file
options:
max-size: 10M
deploy:
labels:
swarmpit.service.deployment.autoredeploy: 'true'
update_config:
delay: 60s
order: start-first
restart_policy:
condition: on-failure
window: 120s
max_attempts: 3
placement:
constraints:
- node.labels.db == 2
db:
image: postgres:14.0-alpine
environment:
POSTGRES_DB: betbeast
POSTGRES_PASSWORD: XbjGAoFf2HLFVV7SkooBswnF3SYQ
POSTGRES_USER: godzilla
volumes:
- betbeast_db_data:/var/lib/postgresql/data
networks:
- databases
- default
logging:
driver: json-file
deploy:
replicas: 0
restart_policy:
condition: on-failure
window: 120s
max_attempts: 3
placement:
constraints:
- node.labels.db == 2
db_backup:
image: tiredofit/db-backup:latest
environment:
COMPRESSION: GZ
CONTAINER_ENABLE_MONITORING: 'FALSE'
DB_CLEANUP_TIME: '10'
DB_DUMP_FREQ: '15'
DB_HOST: db
DB_NAME: betbeast
DB_PASS: XbjGAoFf2HLFVV7SkooBswnF3SYQ
DB_TYPE: pgsql
DB_USER: godzilla
ENABLE_CHECKSUM: 'FALSE'
volumes:
- /mnt/s3_share/backups/databases:/backup
networks:
- default
logging:
driver: json-file
deploy:
restart_policy:
condition: on-failure
window: 120s
max_attempts: 3
redis:
image: redis:6.0-alpine
volumes:
- betbeast_redis:/data
networks:
- default
logging:
driver: json-file
deploy:
placement:
constraints:
- node.labels.db == 2
networks:
databases:
external: true
default:
driver: overlay
routable:
external: true
volumes:
betbeast_db_data:
betbeast_redis:
configs:
betbeast:
external: true