Skip to content

Commit

Permalink
Add more ENVs
Browse files Browse the repository at this point in the history
  • Loading branch information
zakariaf committed Nov 13, 2022
1 parent b9b2fce commit 1443bc4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 19 deletions.
66 changes: 51 additions & 15 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,62 @@
export COMPOSE_PROJECT_NAME=baseapp

# Which environment is running? These should be "development" or "production".
#export RAILS_ENV=production
#export NODE_ENV=production
export RAILS_ENV=development
export NODE_ENV=development

## Secret keys
# You can use `rails secret` command to generate a secret key
export SECRET_KEY_BASE=insecure-key
export DEVISE_JWT_SECRET_KEY=my-jwt-secret-key

# About COMPOSE_PROFILES: https://docs.docker.com/compose/profiles/
# In development we want all services to start but in production you don't
# need the asset watchers to run since assets get built into the image.
#
# You can even choose not to run postgres and redis in prod if you plan to use
# managed cloud services. Everything "just works", even optional depends_on!
#export COMPOSE_PROFILES=postgres,redis,web,worker,cable
export RAILS_ENV=development
export NODE_ENV=development
export COMPOSE_PROFILES=postgres,redis,assets,web,worker,cable
#export RAILS_ENV=production
#export NODE_ENV=production
#export COMPOSE_PROFILES=postgres,redis,web,worker,cable

# What volume path should be used? In dev we want to volume mount everything
# so that we can develop our code without rebuilding our Docker images.
export DOCKER_WEB_VOLUME=.:/app
#export DOCKER_WEB_VOLUME=./public:/app/public

# Should Docker restart your containers if they go down in unexpected ways?
#export DOCKER_RESTART_POLICY=unless-stopped
export DOCKER_RESTART_POLICY=no

# What ip:port should be published back to the Docker host for the app server?
# If you're using Docker Toolbox or a custom VM you can't use 127.0.0.1. This
# is being overwritten in dev to be compatible with more dev environments.
#
# If you have a port conflict because something else is using 3000 then you
# can either stop that process or change 3000 to be something else.
#
# Use the default in production to avoid having puma directly accessible to
# the internet since it'll very likely be behind nginx or a load balancer.
#export DOCKER_WEB_PORT_FORWARD=127.0.0.1:3000
export DOCKER_WEB_PORT_FORWARD=3000

# This is the same as above except for Action Cable.
#export DOCKER_CABLE_PORT_FORWARD=127.0.0.1:28080
export DOCKER_CABLE_PORT_FORWARD=28080

# What CPU and memory constraints will be added to your services? When left at
# 0 they will happily use as much as needed.
# export DOCKER_POSTGRES_CPUS=0
# export DOCKER_POSTGRES_MEMORY=0
# export DOCKER_REDIS_CPUS=0
# export DOCKER_REDIS_MEMORY=0
# export DOCKER_WEB_CPUS=0
# export DOCKER_WEB_MEMORY=0
# export DOCKER_WORKER_CPUS=0
# export DOCKER_WORKER_MEMORY=0
# export DOCKER_CABLE_CPUS=0
# export DOCKER_CABLE_MEMORY=0

## Secret keys
# You can use `rails secret` command to generate a secret key
export SECRET_KEY_BASE=insecure-key
export DEVISE_JWT_SECRET_KEY=my-jwt-secret-key

## Host
export DEFAULT_HOST=example.com
Expand All @@ -32,8 +71,8 @@ export DEFAULT_HOST=example.com
# export RAILS_MIN_THREADS=5

## Postgres
# export POSTGRES_HOST=postgres
# export POSTGRES_PORT=5432
export POSTGRES_HOST=postgres
export POSTGRES_PORT=5432
export POSTGRES_USER=baseapp
export POSTGRES_PASSWORD=123456
export POSTGRES_DB=baseapp
Expand All @@ -53,8 +92,5 @@ export POSTGRES_DB=baseapp
# export SIDEKIQ_WEB_USERNAME=sidekiq-web-dashboard
# export SIDEKIQ_WEB_PASSWORD=sidekiq-web-123

## Vite
export VITE_RUBY_HOST=0.0.0.0

# frontend config
VITE_API_URL=http://localhost:3000
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN apk add --update \
nodejs=$NODE_VERSION \
yarn=$YARN_VERSION

######################################################################

# This stage will be responsible for installing gems and npm packages
FROM base AS dependencies

Expand All @@ -36,7 +38,7 @@ COPY package.json yarn.lock ./
# Install npm packages
RUN yarn install --frozen-lockfile

###############################################################################
######################################################################

# We're back at the base stage
FROM base AS app
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ services:
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
# POSTGRES_DB: "${POSTGRES_DB}"
image: "postgres:15.0-alpine"
profiles: ["postgres"]
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
stop_grace_period: "3s"
volumes:
- "postgres:/var/lib/postgresql/data"
profiles: ["postgres"]

redis:
deploy:
Expand All @@ -41,11 +41,11 @@ services:
cpus: "${DOCKER_REDIS_CPUS:-0}"
memory: "${DOCKER_REDIS_MEMORY:-0}"
image: "redis:7.0.5-alpine"
profiles: ["redis"]
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
stop_grace_period: "3s"
volumes:
- "redis:/data"
profiles: ["redis"]

web:
<<: *default-app
Expand Down Expand Up @@ -95,7 +95,6 @@ services:

vite:
<<: *default-app
profiles: ["assets"]
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
stop_grace_period: "3s"
tty: true
Expand All @@ -107,6 +106,7 @@ services:
- .:/app
environment:
VITE_RUBY_HOST: 0.0.0.0
profiles: ["assets"]

volumes:
postgres: {}
Expand Down

0 comments on commit 1443bc4

Please sign in to comment.