Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.git
.dockerignore
.env
.vscode
node_modules/
bundle/
tmp/
.env*
environment/artifacts

.bundle
.env
.env.*
.git
.gitattributes
.gitignore
.github
public/system
public/assets
public/packs
node_modules
neo4j
vendor/bundle
.DS_Store
*.swp
*~
postgres
postgres14
redis
elasticsearch
chart
docker-compose*
12 changes: 9 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:

services:
postgres:
image: postgres:11.7-alpine
image: postgres:13.7-alpine
env:
POSTGRES_USER: outpost
POSTGRES_PASSWORD: password
POSTGRES_USER: outpost_test
POSTGRES_PASSWORD: outpost_test
POSTGRES_DB: outpost_test
ports:
- 5432:5432
Expand Down Expand Up @@ -61,7 +61,9 @@ jobs:
- name: Setup database
env:
RAILS_ENV: test
SECRET_TOKEN: ${{ secrets.SECRET_TOKEN }}
DB_URI: mongodb://root:password@localhost:27017/outpost_development?authSource=admin
DATABASE_URL: postgresql://outpost_test:outpost_test@localhost:5432/outpost_test?timeout=5000
run: |
bundle exec rails db:drop
bundle exec rails db:create
Expand All @@ -70,6 +72,8 @@ jobs:
- name: Compile assets
env:
RAILS_ENV: test
SECRET_TOKEN: ${{ secrets.SECRET_TOKEN }}
DATABASE_URL: postgresql://outpost_test:outpost_test@localhost:5432/outpost_test?timeout=5000
run: |
bundle exec rails assets:precompile

Expand All @@ -78,6 +82,8 @@ jobs:
RAILS_ENV: test
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
OFSTED_FEED_API_ENDPOINT: https://test-ofsted-feed.stub # this is not a real url, we just need an env variable set for the stub to work in tests
SECRET_TOKEN: ${{ secrets.SECRET_TOKEN }}
DATABASE_URL: postgresql://outpost_test:outpost_test@localhost:5432/outpost_test?timeout=5000
run: |
bundle exec rspec

Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ yarn-debug.log*

.DS_Store
yarn.lock
.vscode
.vscode

/environment/artifacts
.env*
89 changes: 89 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# using docker image layers to save waiting for things to rebuild all the time
# base_image > build_rails > build_frontend > development

FROM ruby:3.0.5-alpine as base_image
RUN apk add --no-cache git \
build-base \
libpq-dev \
tzdata \
gcompat \
python3

# gcompat is for nokogiri - alpine doesnt include glibc it needs https://nokogiri.org/tutorials/installing_nokogiri.html#linux-musl-error-loading-shared-library
# python2 for node-sass drama

# install node v16
# see here for reference https://github.com/timbru31/docker-ruby-node/blob/master/3.0/16/alpine/Dockerfile
RUN apk -U upgrade \
&& apk add --repository https://dl-cdn.alpinelinux.org/alpine/v3.16/main/ --no-cache \
"nodejs<18" \
&& apk add --no-cache \
npm \
yarn

# install various gems
FROM base_image as build_app
COPY ./Gemfile /tmp/Gemfile
COPY ./Gemfile.lock /tmp/Gemfile.lock
COPY ./package.json /tmp/package.json
COPY ./yarn.lock /tmp/yarn.lock

RUN cd /tmp && \
bundle install && \
yarn install && \
apk add --no-cache git



WORKDIR /app

FROM build_app as base_env
COPY --from=build_app /tmp .


# build and install all the things for the development env
FROM base_env as development
COPY ./environment/docker-run-development.sh /rdebug_ide/runner.sh
RUN gem install ruby-debug-ide && \
chmod +x /rdebug_ide/runner.sh

ENV RAILS_ENV="development" \
NODE_ENV="development" \
RAILS_SERVE_STATIC_FILES="false"
EXPOSE 3000
# ENTRYPOINT ["tail", "-f", "/dev/null"]
CMD ["/rdebug_ide/runner.sh"]
# CMD bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -u puma -p 3000 -b '0.0.0.0'"
# ENTRYPOINT ["tail", "-f", "/dev/null"]


FROM base_env as test
COPY ./environment/docker-run-production.sh /runner/runner.sh
COPY . .
RUN chmod +x /runner/runner.sh
RUN bundle exec rails assets:precompile
EXPOSE 3000
ENV RAILS_ENV="test" \
NODE_ENV="test" \
RAILS_SERVE_STATIC_FILES="true"
CMD ["/runner/runner.sh"]

# build and install all the things for the production env
FROM base_env as production
COPY ./environment/docker-run-production.sh /runner/runner.sh
COPY . .
RUN chmod +x /runner/runner.sh
EXPOSE 3000

ENV RAILS_ENV="production" \
NODE_ENV="production" \
RAILS_SERVE_STATIC_FILES="true"

# ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/runner/runner.sh"]
# ENTRYPOINT ["/usr/bin/tini", "--"]
# CMD bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -u puma -p 3000 -b '0.0.0.0'"
# ENTRYPOINT ['./environment/docker-run-production.sh']
# CMD ["rails", "s", "-p", "3000"]
# ENTRYPOINT ["tail", "-f", "/dev/null"]

Loading