์ž์‹ ์˜ dev.to ๐Ÿณ ์„œ๋ฒ„๋ฅผ ์‹œ์ž‘ํ•˜์„ธ์š” - ๋‹จ์ผ ๋ช…๋ น์œผ๋กœ (๊ฑฐ์˜)!

16737 ๋‹จ์–ด metashowdevdockeropensource
(๋ฉด์ฑ… ์กฐํ•ญ bash ์Šคํฌ๋ฆฝํŠธ๋Š” ๋„์ปค๊ฐ€ ์žˆ๋Š” Ubuntu/MacOS์—์„œ๋งŒ ํ…Œ์ŠคํŠธ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.)

๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋ณต์ œํ•˜๊ณ  bash ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•œ ๋‹ค์Œ ํ™”๋ฉด์˜ ์ง€์นจ์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค.

git clone https://github.com/uilicious/dev.to-docker.git && \
cd dev.to-docker && sudo ./docker-run.sh INTERACTIVE-DEMO



๋” ๊ธด ๋„์ปค ๊ธฐ๋ฐ˜ ๋ช…๋ น(git clone ์—†์Œ)



์ฐธ๊ณ : ๋‹ค์–‘ํ•œ<values>์„ ๋ชจ๋‘ ๊ต์ฒดํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

# Run a postgres server configured for dev.to
docker run -d --name dev-to-postgres \
    -e POSTGRES_PASSWORD=devto \
    -e POSTGRES_USER=devto \
    -e POSTGRES_DB=PracticalDeveloper_development \
    -v "<POSTGRES_DATA>:/var/lib/postgresql/data" \
    postgres:10.7-alpine;

# Wait about 30 seconds, to give the postgres container time to start
sleep 30

#
# Run the prebuilt dev.to container
# binded to localhost:3000
#
# Algoliasearch API key is required for dev.to,
# for login do consider adding github/twitter keys as well
# see : https://github.com/thepracticaldev/dev.to/blob/master/config/sample_application.yml
#
docker run -d -p 3000:3000 \
    --name dev-to-app \
    --link dev-to-postgres:db \
    -v "<DEVTO_UPLOAD_DIR>:/usr/src/app/public/uploads/" \
    -e ALGOLIASEARCH_APPLICATION_ID=<APP_ID> \
    -e ALGOLIASEARCH_SEARCH_ONLY_KEY=<SEARH_KEY> \
    -e ALGOLIASEARCH_API_KEY=<ADMIN_KEY> \
    uilicious/dev.to

#
# Also : do give 5~10 minutes for the server to be up. 
# It does take a long time to setup and start
#

Docker ํ—ˆ๋ธŒ ๋งํฌ:




Btw: ์ƒˆ ๋ฐฐํฌ์—์„œ ์ƒ์„ฑ๋œ ๋‹ค์–‘ํ•œ ๋ฌด์ž‘์œ„ ๊ธฐ์‚ฌ ์ œ๋ชฉ์ด ๋งค์šฐ ์žฌ๋ฏธ์žˆ์Šต๋‹ˆ๋‹ค.









PicoCreator
์— ๊ฒŒ์‹œ๋จ




์ด๊ฒƒ์€ ์–ด๋–ค ์œ ํ˜•์˜ PR์ž…๋‹ˆ๊นŒ? (ํ•ด๋‹น๋˜๋Š” ํ•ญ๋ชฉ ๋ชจ๋‘ ์ฒดํฌ)


  • [ ] ๋ฆฌํŒฉํ„ฐ๋ง
  • [x] ๊ธฐ๋Šฅ
  • [ ] ๋ฒ„๊ทธ ์ˆ˜์ •
  • [ ] ์„ค๋ช…์„œ ์—…๋ฐ์ดํŠธ

  • ์„ค๋ช…


    DEV ๋˜๋Š” DEMO ํ™˜๊ฒฝ์„ ๋น ๋ฅด๊ฒŒ ์„ค์ •ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋˜๋Š” ๋‹จ์ผ bash ์Šคํฌ๋ฆฝํŠธ
    bash-3.2$ ./docker-run.sh 
    #---
    #
    # This script will perform the following steps ... 
    #
    # 1) Stop and remove any docker container with the name 'dev-to-postgres' and 'dev-to'
    # 2) Reset any storage directories if RUN_MODE starts with 'RESET-'
    # 3) Build the dev.to docker image, with the name of 'dev-to:dev' or 'dev-to:demo'
    # 4) Deploy the postgres container, mounting '_docker-storage/postgres' with the name 'dev-to-postgres'
    # 5) Deploy the dev-to container, with the name of 'dev-to-app', and sets up its port to 3000
    #
    # To run this script properly, execute with the following (inside the dev.to repository folder)...
    # './docker-run.sh [RUN_MODE] [Additional docker envrionment arguments]'
    #
    # Alternatively to run this script in 'interactive mode' simply run
    # './docker-run.sh INTERACTIVE-DEMO'
    #
    #---
    #---
    #
    # RUN_MODE can either be the following
    #
    # - 'DEV'  : Start up the container into bash, with a quick start guide
    # - 'DEMO' : Start up the container, and run dev.to (requries ALGOLIA environment variables)
    # - 'RESET-DEV'   : Resets postgresql and upload data directory for a clean deployment, before running as DEV mode
    # - 'RESET-DEMO'  : Resets postgresql and upload data directory for a clean deployment, before running as DEMO mode
    # - 'INTERACTIVE-DEMO' : Runs this script in 'interactive' mode to setup the 'DEMO'
    #
    # So for example to run a development container in bash its simply
    # './docker-run.sh DEV'
    #
    # To run a simple demo, with some dummy data (replace <?> with the actual keys)
    # './docker-run.sh DEMO -e ALGOLIASEARCH_APPLICATION_ID=<?> -e ALGOLIASEARCH_SEARCH_ONLY_KEY=<?> -e ALGOLIASEARCH_API_KEY=<?>'
    #
    # Finally to run a working demo, you will need to provide either...
    # './docker-run.sh .... -e GITHUB_KEY=<?> -e GITHUB_SECRET=<?> -e GITHUB_TOKEN=<?>
    #
    # And / Or ...
    # './docker-run.sh .... -e TWITTER_ACCESS_TOKEN=<?> -e TWITTER_ACCESS_TOKEN_SECRET=<?> -e TWITTER_KEY=<?> -e TWITTER_SECRET=<?>
    #
    # Note that all of this can also be configured via ENVIRONMENT variables prior to running the script
    #
    #---

    And does the deployment using docker. Includes option to do a reset prior to deployment.

    Optional contextual information provided here :

    ์— ๋Œ€ํ•œ ์กฐ์–ธ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค ...

    if someone can guide me on how to run dev.to in "Production" mode, it would be great in improving the overall docker container performance

    ๋ฌธ์„œ์— ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๊นŒ?

    • sample readme for docker hub :
    • I can modify readme if this looks good?

    ์ด PR์„ ๊ฐ€์žฅ ์ž˜ ์„ค๋ช…ํ•˜๋Š” gif๋Š” ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?

    ๊ธฐ๋ถ„์„ ๊ฐ€์žฅ ์ž˜ ๋‚˜ํƒ€๋‚ด๋Š” gif๋Š” ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?

    PS: if someone can guide me on how to run dev.to in "Production" mode, it would be great in improving the overall docker container performance, in such a setup.


    ์™œ ์ด๋Ÿฌ๋Š” ๊ฑฐ์ง€? ๊ณต์‹ readme๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„œ๋ฒ„๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๊นŒ?

    Well it started out with that, and ...

    Its not a problem specifically about dev.to, its simply me being not a ruby developer.

    All I wanted was to simply spin up a quick server, so that I can try writing some UI test scripts on it (more on that later).

    I really didn't want to be figuring out how to install ruby, sorting out missing os dependencies, and fix my npm versions, trying to figure out why the existing docker build have missing images, etc, etc.......

    And in the middle of fixing all that, a flashback hit me ...

    For this future where dev.to grows into a series of decentralised dev.to.like networks operated by the community to happen. We need the site to be something that is quick, and easy to deploy for anyone.

    Not just someone who "needs" to know how to ruby, postgres, nodejs, or even docker and docker compose for that matter...

    We already have hundreds of other more human hurdles in place to get a software adopted...

    And in my subjective experience, the ability to get quick one liner demo up and running goes a long way in convincing others... Less is truly more here...

    Convincing others in going beyond using https://dev.to/ itself, but to use its open source codebase, perhaps adapt it to their own needs, or more importantly contribute to it!

    For homebrew users, think of how many times have you used this one line for yourself or others

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    ๋„์›€์ด ๋˜์ง€ ์•Š๋‚˜์š”?

    The current script might not yet be there (for example we could auto install docker if its not present, and maybe in the future break the hard reliance on Algolia). But its one more step into that direction.




    UI ํ…Œ์ŠคํŠธ์— ๋Œ€ํ•ด ๋ญ๋ผ๊ณ  ํ•˜์…จ์Šต๋‹ˆ๊นŒ?



    ๋‚ด๊ฐ€ uilicious์—์„œ ์ž‘์—…ํ•˜๋Š” ๊ฒƒ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ…Œ์ŠคํŠธ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

    // Lets go to dev.to
    I.goTo("https://dev.to")
    
    // Fill up search
    I.fill("Search", "uilicious")
    I.pressEnter()
    
    // I should see myself or my co-founder
    I.see("Shi Ling")
    I.see("Eugene Cheah")
    

    ํœ˜์ “๋‹ค sharable test result



    ์œ„์™€ ๊ฐ™์ด.

    ๊ทธ๋Ÿฌ๋‚˜ ์—ฌ๊ธฐ์—๋Š” ํ•œ ๊ฐ€์ง€ ํฐ ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. Uilicious๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์ผ๋ฐ˜์ ์œผ๋กœ UI ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด ํ•ด๊ฒฐํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค...

    ์–ด๋Š ๊ฒƒ์ด ๋ชจ๋‘๋ฅผ ์–ป๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค ... UI ํ…Œ์ŠคํŠธ๊ฐ€ ์ปค๋ฐ‹๋˜๋Š” ์ฆ‰์‹œ ์‹คํ–‰ํ•˜๋ ค๋ฉด ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. (๊ฐœ๋ฐœ ํšŒ์‚ฌ, ๊ณ ๊ฐ ๋˜๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ๋ชจ๋“  ๊ฐœ๋ฐœ์ž์—๊ฒŒ ์œ ์šฉํ•จ)

    ๋ถˆํ–‰ํ•˜๊ฒŒ๋„ ๋‚ด๊ฐ€ ๋ณธ ๋ฐ”๋กœ๋Š” ์šฐ๋ฆฌ ํ”Œ๋žซํผ์˜ ๋Œ€๋ถ€๋ถ„์˜ ์‚ฌ์šฉ์ž๋Š” ํ”„๋กœ๋•์…˜์—์„œ๋งŒ ํ…Œ์ŠคํŠธํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํ…Œ์ŠคํŠธ/์Šคํ…Œ์ด์ง• ์„œ๋ฒ„๊ฐ€ ์ ˆ๋ฐ˜๋ณด๋‹ค ์•ฝ๊ฐ„ ์ ์Šต๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ git push์— ๋Œ€ํ•œ ์•„์ฃผ ์ž‘์€ ๋ถ€๋ถ„ ํ…Œ์ŠคํŠธ์ž…๋‹ˆ๋‹ค.



    ๊ฐœ๋ฐœ ๊ณผ์ •์—์„œ ํ…Œ์ŠคํŠธ๊ฐ€ ์‹คํŒจํ•˜๊ณ  ๊ฐœ๋ฐœ์ž์—๊ฒŒ ์•Œ๋ฆฌ๋Š” ๊ฒƒ์ด ๋น ๋ฅด๋ฉด ๋น ๋ฅผ์ˆ˜๋ก ๋ชจ๋“  ์‚ฌ๋žŒ์—๊ฒŒ ๋” ์ข‹์Šต๋‹ˆ๋‹ค.

    ๊ทธ๋ฆฌ๊ณ  ์ผ๋ฐ˜์ ์œผ๋กœ ๊ฑฐ๊ธฐ์— ๋„๋‹ฌํ•˜๋Š” ๋ฐ ๊ฐ€์žฅ ํฐ ์žฅ์• ๋ฌผ์€ ์ž๋™ํ™”๋œ UI ํ…Œ์ŠคํŠธ๋ฅผ ๋ฐ›๋Š” ๊ฒƒ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ...

    Can you make a build in one step? : If the process takes any more than one step, it is prone to errors
    ~ over simplifying Joel Spolsky



    ๋˜๋Š” ๋” ๊ตฌ์ฒด์ ์œผ๋กœ ๋นŒ๋“œ, ๋ฐฐํฌ ๋ฐ ํ…Œ์ŠคํŠธ๋ฅผ ํ•œ ๋‹จ๊ณ„๋กœ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

    ๋”ฐ๋ผ์„œ dev.to๋ฅผ ๋” ์‰ฝ๊ฒŒ ๋งŒ๋“ค๊ณ  ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๊ฒƒ์ด ์ €์˜ ์ž‘์€ ํฌ๋ง์ž…๋‹ˆ๋‹ค.

    ๋‹ค์Œ์— ํ•ด์•ผ ํ•  ์ผ์€(๋‹ค์Œ ๊ธฐ์‚ฌ์˜ @TODO) ์ž„์‹œ ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด travis์™€ ํ•จ๊ป˜ ์—ฐ๊ฒฐํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ git ํ‘ธ์‹œ๋กœ UI ํ…Œ์ŠคํŠธ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” ํ”„๋กœ์„ธ์Šค์ž…๋‹ˆ๋‹ค.

    ํŠน์ • git ํ‘ธ์‹œ์— ๋Œ€ํ•œ ์ „์ฒด UI ํ…Œ์ŠคํŠธ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋Š” ๋‹ค๋ฅธ ๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ ์˜ˆ์‹œ ์‚ฌ์šฉ ์‚ฌ๋ก€๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค....

    ๊ทธ๋ฆฌ๊ณ  ์•„๋งˆ๋„ ์•„๋งˆ๋„ ์•„๋งˆ๋„ dev.to team to sign up for our product. or free trial ๐Ÿ˜‰


    ์•„, ํ•œ ๊ฐ€์ง€ ๋” - DEV ๋ชจ๋“œ



    ./docker-run.sh DEV
    



    ํ…Œ์ŠคํŠธ ๋ฐ ๋ฐ๋ชจ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๊ฐœ๋ฐœ์—๋„ ๋„์›€์ด ๋˜๋Š” ๋‹จ์ผ bash ์Šคํฌ๋ฆฝํŠธ.

    ๋ณต์ œ๋œ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—์„œ ๋ฐ”๋กœ bash๋กœ ์ „์ฒด ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ์„ค์ •ํ•˜๋Š” ํ•œ ์ค„ ๋ช…๋ น์ž…๋‹ˆ๋‹ค.

    ruby/npm ์„ค์น˜๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.


    PS : If anyone have feedback how I can make this build and deploy script better / etc. Do let me know



    ์ฆ๊ฑฐ์šด ๋ฐฐ์†ก๐Ÿ––๐Ÿผ๐Ÿš€

    ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ