Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine docker-compose.yml: #799

Merged
merged 4 commits into from
May 14, 2023

Conversation

zw963
Copy link
Contributor

@zw963 zw963 commented Apr 23, 2023

Fixes #798

  1. use short volume bind syntax.
  2. fix postgres volume issue. check When create a new lucky app, the postgres_data volume never work as expected. #798.
  3. Add POSTGRES_DB env for clarify, check Some question(discuss) for docker-compose.yml of lucky 1.0.0. lucky#1791
  4. Add crystal build cache into volume for better performance.

1. use short volume bind syntax.
2. fix postgres volume issue.
   check luckyframework#798
3. Add POSTGRES_DB env for clarify.
   check luckyframework/lucky#1791
4. Add crystal build cache into volume for better performance.
@zw963 zw963 force-pushed the bugfix/docker-compose_config branch from ed43045 to 18e0ba7 Compare April 23, 2023 04:20
@zw963
Copy link
Contributor Author

zw963 commented Apr 23, 2023

In fact, for users what to deploy app use docker-compose, there is a better solution to split docker-compose.yml to two file, check following example.

  1. PROJECT_ROOT/docker-compose.yml
version: "3"
services:
  app:
    build:
      context: .
    ports:
      - ${APP_PORT}:3000
    environment:
      DATABASE_URL: postgres://${DB_USERNAME}:${DB_PASSWORD}@db:${DB_PORT}/${DB_NAME}
    depends_on:
      - db
  db:
    image: postgres:14-alpine
    environment:
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: ${DB_NAME}
  1. All development related config only save in PROJECT_ROOT/docker/dev/docker-compose.yml
version: "3.8"
services:
  app:
    build:
      dockerfile: docker/development.dockerfile
    environment:
      DEV_HOST: "0.0.0.0"
    volumes:
      - .:/app
      - node_modules:/app/node_modules
      - shards_lib:/app/lib
      - build_cache:/root/.cache/crystal
    ports:
      - 3001:3001 # This is the Lucky watcher reload port

    entrypoint: ["docker/dev_entrypoint.sh"]

  db:
    volumes:
      - pg_data:/var/lib/postgresql/data
    ports:
      - 6543:5432

volumes:
  pg_data:
  node_modules:
  shards_lib:
  build_cache:

Then, start user development docker-compose like this:

$: docker-compose -f docker-compose.yml -f docker/dev/docker-compose.yml up

I use a bash alias instead.

$: dc="docker-compose --env-file .env -f docker-compose.yml -f docker/dev/docker-compose.yml"
$: dc up

@zw963
Copy link
Contributor Author

zw963 commented Apr 26, 2023

Have no idea for why spec/flows/security_spec.cr failed.

Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for contributing.

@jwoertink jwoertink merged commit 161fe88 into luckyframework:main May 14, 2023
@zw963 zw963 deleted the bugfix/docker-compose_config branch May 16, 2023 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When create a new lucky app, the postgres_data volume never work as expected.
2 participants