Commit graph

26 commits

Author SHA1 Message Date
Mac Siri
20faec4899
Support chromedriver in container (#20224) 2023-10-16 15:12:53 -04:00
Mac Siri
5dc7e889b9
Support devcontainers and GitHub codespace (#20126)
Co-authored-by: Josh Klar <jklar@forem.com>
2023-09-21 18:16:09 -04:00
Mac Siri
ca6e635549
Improve docker local development (#19996) 2023-09-01 14:13:40 -04:00
Daniel Uber
b35c1a575f
Add a minimal test database setup to the docker-compose file (#16305)
This provides a test environment database for anyone using a docker
based development environment.

Expose, rather than bind, the db port (you won't be able to connect to
the db externally, only from the container).

Add tmpfs storage (this alleviates an issue seen with carrierwave
attachments when trying to write to the tmp directory in the image).

Upgrade db versions from 11 to 13 (this is a breaking change for
anyone using this who had already provisioned the db, since no attempt
to upgrade has been provided, users may either downgrade to the
11-alpine image or recreate their storage volume). This is
separable (the `db` container was preexisting so is the only upgrade
conflict for users, the `testdb` container is newly created in a newly
added volume, and should not rely on persistence).

It's possible no volume is needed for the test db (only the schema
would normally be persisted, since data is truncated after normal test completion).
2022-01-31 09:22:38 -06:00
Daniel Uber
a1c27cc47d
Update docker-compose.yml file to permit login (#13792)
There was an issue seen with the HTTP Origin header not matching (the
error unhelpfully reported localhost:3000 did not match
localhost:3000).

Change the APP_DOMAIN internally to localhost:3000 (which is what the
user will in fact use, not rails), and since that breaks the http
requests from the db seed and sidekiq containers, allow them to only
check for a tcp connection instead of expecting a 200
response (sending requests to the disallowed host `rails` triggered a
403).

Related to discussion in https://github.com/forem/forem/issues/4955
2021-05-24 20:03:36 -05:00
Alex
393ba00221
Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606)
* Attempt number 1

* Fix rack_attack specs

* Fix users_searches_users spec

* Fix display_users_search_spec

* Fix comment typo

* Remove search:destroy task from cypress

* Remove port 9300 from gitpod

* Stub response in attack_spec
2021-05-03 11:09:45 -04:00
Matthew O'Brien
ecb8b270ea
Use wait-retry-interval parameter for dockerize (#12101)
The default retry interval for dockerize when using the `wait`
parameter is 1s. Because it takes several seconds, at least, to boot
up elasticsearch and bundler, the `rails` and `webpacker` services
generate a number of retry messages.

The `seed` and `sidekiq` services both wait for `rails` service to be
up and running. That takes time as well, and these two generate a
sometimes overwhelming level of output.

This change sets the retry interval for dockerize to 10s for `rails`
and `webpacker` and 20s for `seed` and `sidekiq`. These choices are
fairly arbitrary, but aim to strike a balance between keeping the
output readable as services start and not excessively delaying start
times.

With bad luck, this could delay start up on the order of 30s. However,
the increased awareness of where the various services are in their
startup process is hopefully a worthwhile tradeoff.
2021-01-05 08:54:42 +01:00
Carlos Eduardo Müller de Carvalho
ba5f25931f
Fix docker-compose (#12063)
* fix docker-compose wait for file from bundle

fix  path for .bundle_finished

* fix yarn on docker-compose
2020-12-29 13:31:32 -05:00
Joe Doss
44569605d2
Fix container composes w/r/t multistage container builds (#11531)
* Use premade development image.

* Use prebuilt container for podman-compose too!

* Fix bundle bundle_finished path.

* Fix docker-compose to work with the Multistage Containerfile

Add root user for Forem containers, fix bundle_finished path and make
webpacker wait for the bundle to finish.

Switch Redis to redis:6.0.9-alpine

* Remove build steps and fix bundle path.

* Merge dev entrypoint into the main one.

* Use merged entrypoint.sh, remove old entrypoint directives, and fix a dockerize bug.

* Make sure unset BUNDLE_WITHOUT and remove without in bundle config.

* Unset BUNDLE_WITHOUT="development:test" as a global ENV.

Also ensure that we remove the without directives for development and testing.
This will make sure that the right gems are installed for each environment.

Removed some unneeded COPYs and remove a commented out RUN.

* Fix ENTRYPOINT on development and testing containers.

* Fix entrypoint and command on rails container.

* Ignore bundle_finished file.

* Fix REDIS_ env vars and adjust podman-compose file.

* Change bundle_finished path and update Yarn docker-compose command.
2020-11-23 15:15:21 -06:00
Joe Doss
1d4685219d
Multistage container builds (#11468)
* WIP multi-stage container build.

* Move to a multistage build process in the Containerfile.

* Enable testing container

* Finalize the multistage build script and Containerfile. Ooof!

I got blocked for a bit with this bugger:

Step 27/32 : COPY --from=builder --chown=${APP_USER}:${APP_USER} ${APP_HOME} ${APP_HOME}
failed to copy files: failed to copy directory: Error processing tar file(exit status 1): Container ID 100999 cannot be mapped to a host ID

but https://github.com/phusion/passenger-docker/issues/235#issuecomment-636318827

was a good shove in the right direction!

* Fix bugs on container build script.

* Adjust compose files to use multistage builds.

* Add in Buildkite pipeline for building containers.

* Update CODEOWNERS to claim ownership over things that Systems Eng cares about
2020-11-19 10:03:35 -06:00
Joe Doss
f34dbf4693
Better production container precompiling and bootstrapping (#10280)
* Create entrypoint-dev.sh to be used with devel workflows with docker/podman compose
and adjust the compose files to use it.

* Adjust the entrypoint script so we have better control over when we run
rake assets:precompile and rake app_initializer:setup.

* Copy vendor/cache so we can bundle install from cached gems instead of
fetching them from the Internet.

* Run rake assets:precompile in the container build.

* Add in clobber and clean tasks to entrypoint.
2020-09-16 16:59:19 -05:00
Joe Doss
c2aa775d12
Sets APP_DOMAIN to rails to fix #9604 (#9624) 2020-08-04 07:55:11 -05:00
Joe Doss
3e0a40741e
Update containers: DEV => Forem (#9611)
This PR moves the away from the dev specific naming to forem w/r/t container
things. Also moves to the Forem quay.io org.

* Move to Forem from DEV
* Add in assets and packs directories.
2020-08-03 16:54:45 -05:00
Molly Struve
fde4d3f189
Update Docs, Travis, and Containers to Use Postgres 11 (#9232)
* Update Docs and Containers to Use Postgres 11<, Bump Travis to 10

* Update installation docs as well

Co-authored-by: rhymes <rhymes@hey.com>
2020-07-13 15:09:26 +02:00
Joe Doss
aa49cb1cfe
Bugfix for #7663 and refactor of container setup (#7747)
* Move from Alpine Linux to Fedora Linux.

This changes the base container image away from Alpine Linux to
Fedora Linux to address some musl libc issues with some of our gems.

It also moved the main file to a Containerfile and symlinks the Dockerfile
to it. This makes our container setup less Docker-centric as Linux users
most likely will be using Podman as their container runtime.

Lastly, it moves the WORKDIR from /usr/src/app to /opt/apps/devto.
The Linux FHS states that /opt is the spot for Optional application
software packages and /usr/src is for kernel source code.

https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

/opt Optional application software packages
/usr/src Source code, e.g., the kernel source code with its header files.

Also, if SELinux becomes a thing in our future, moving this makes it
easier to manage contexts out of /opt rather than /usr/src.

* Adjust the Containerfile a bit to add some missing packages, make it
more generic and move env vars to the docker-compose.

* Move the Dockerfile to a symlink to the Containerfile.

We need to be able to support more than just Docker for a container
runtime. Moving everything to a Containerfile and symlinking the
Dockerfile helps users run runtimes such as Podman.

* Add in new entrypoint files and fix the app path in docker-entrypoint.sh

* Refactor the docker-compose.yml file so it doesn't build the main
application container three times in a row. We can use the same
container for web, webpacker, and sidekiq.

Also make the volume names very explicit on what their contents and add
in SELinux context support with :Z

* Fix ELASTICSEARCH_URL.

* Remove the absolute path on ip binary and add in iproute to Containerfile.

* Symlink the Dockerfile to Containerfile and add in a container-compose.yml file
for usage with podman-compose. We are waiting for this issue to get resolved

https://github.com/containers/libpod/issues/6153

and for podman-compose to mature a bit more. A user using podman-compose can use

podman-compose -f container-compose.yml

to launch the DEV container stack with Podman.

* Update the .gitignore file to reflect the new container volumes.

* Fix the entrypoint script on the Containerfile and clean up a bunch of things.

* Rework the Containerfile to prep it to run as a non-root user. We have to wait
for this issue to get fixed:

https://github.com/containers/libpod/issues/6153

for Linux users and then we can uncomment the USER line so we are running Rails
as a non-root user. :toot:

* This reworks the compose files so each task that is needed to start the app has
a correct wait command with dockerize. It also adds in containers for doing
yarn and bundle things for development. Since we mount the code directory inside
the container we lose our pre-containerized gems and node_modules.

This means users can run:

Linux
podman-compose -f container-compose.yml up

Mac
docker-compose up

and it should correctly build the app stack with containers!

* Clean up old container related things.

* Add in some container pre-reqs and my name to the "Core team" section! :toot:

* Adjust the seed and sidekiq compose entries so they do not use the web entrypoint
and set the REDIS_URL and REDIS_SESSIONS_URL env vars for seed.

Add in some echos to the entrypoint.sh.

Also set docker-compose to use :delegated on mount points to speed things up.

https://docs.docker.com/storage/bind-mounts/#configure-mount-consistency-for-macos

* Just call yarn install --dev on the yarn container.

* Update documentation to support Docker and Podman as Container Engines and
move the page from docker to containers to reflect the fact not all users run
their containers via Docker.

There are dozens of us... DOZENS!

* Set --local on bundle config so it just impacts this Ruby app.

* Renamed bin/docker-setup to bin/container-setup to reflect the fact that that
we can use Podman as a container engine. I also refactored it so it does some
basic pre-flight checks for docker and docker-compose or podman and
podman-compose to make sure users have a container engine installed.

* Set cache_all_platforms true for bundler.

* Bump docker-compose dockerize -timeout to 45min for slower macOS hardware.

* Move to the consolidated app_initializer:setup rake task for bootstrapping the
app.

* Update docs/installation/readme.md
2020-05-28 12:11:51 -05:00
Thai Pangsakulyanont
5d97ca86c5
Improve docker setup script (#7378)
* Add set -e to docker-setup script

* Add error handling for db setup stage

* Sometimes Elasticsearch takes time to boot up

* Also delete docker_data

* search:setup must come first

* Revert "Sometimes Elasticsearch takes time to boot up"

This reverts commit e975f6e5c3edad084d4f2c4d8718675bf5c8d07c.

Reason for revert:
Instead of using wait-on, we can use Docker’s health check instead

See review comment:
https://github.com/thepracticaldev/dev.to/pull/7378#discussion_r411839255

* Use wait-on without installing into package.json

* Add /usr/src/app/node_modules to volumes

Otherwise, webpacker will not run in docker-compose.

See: https://stackoverflow.com/questions/30043872/docker-compose-node-modules-not-present-in-a-volume-after-npm-install-succeeds
2020-04-24 18:45:27 -04:00
rhymes
db9186043e
Removed yarn integrity check (#7478) 2020-04-23 19:23:12 -04:00
briwa
09f0773c18
refactor(docker): move redis env config to docker (#6936)
instead of in config/application.yml
2020-03-30 10:48:38 +07:00
Abenet Tamiru
83a59063fc
Set user, password and db for postgres docker (#6564)
* Set user, password and db for postgres docker

* Sync other docker services with dockerfile DATABASE_URL
2020-03-10 14:44:26 -04:00
Molly Struve
6a277ba10d
remove rake jobs:work references from code (#6082) [deploy] 2020-02-14 15:18:08 -05:00
Michael Kohl
f1aca16a1e
Improve Docker configuration (#6055) 2020-02-14 14:28:27 -05:00
Michael Kohl
38e980917d
Add Elasticsearch to Docker Compose (#5978)
* Copy .ruby-version into Dockerfile
* Add Elasticsearch to Docker Compose
2020-02-11 11:45:16 -05:00
Mohamed ABDELLANI
0039e67467 Add redis container to docker-compose (#4965)
* Add redis container to docker-compose [fix issue 4962]

* Updates docker.md
2019-11-29 17:06:56 -05:00
Abenet Tamiru
4c873c1a88 Specify postgres version in docker-compose.yml (#4477) [ci skip] 2019-10-17 10:55:06 -04:00
Hector Bustillos
27a7a199d7 #4129 Reduce Dockerfile size (#4251)
* The previous Dockerfile was using and outdated format and was causing
heavy load times.

The number of the lines in the Dockerfile are defined as layer, with more
layers more time and bigger is the final image.

There were many things that were able to be delegated to the official ruby
docker image.

*  - Use yarn community package
 - Don't create the workdir directory since is created by docker if doesn't exists
 - Remove config/application.yml from .dockerignore

* Update Dockerfile

Co-Authored-By: Abenet Tamiru <mail@abenet.me>

* Update Dockerfile

Co-Authored-By: Abenet Tamiru <mail@abenet.me>

* Add directory copy, and user correct folder in compose

* Update docker-compose and Dockerfile

* Fix typo

Co-Authored-By: Mac Siri <krairit.siri@gmail.com>

* Update wording

Co-Authored-By: Mac Siri <krairit.siri@gmail.com>
2019-10-10 18:01:04 -04:00
Michael
cfda390845 Adds optional support for Docker/Compose (#296)
* Adds optional support for Docker/Compose

* Upgrades Dockerfile to use a multi-stage build

* Gets rest of stack running in Docker

* Renames queue to jobs, uses jobs namespace command

* Reverts file

* Adds webpacker

* Fixes yarn check issue

* Adds Database URL default connection string

* Remove daemons gem

* Update huskyhook config

* Update seed.rb

* Create .dockerignore

* Increase RackTimeout's config

* Simplify Docker config

* Update README

* Remove postgres url default

* Change docker entry point to 3000

* Remove duped integrity setting
2018-10-12 11:48:53 -04:00