ASTRO Camp 11th
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 20220824 Docker/部署Heroku/Rails7 ###### tags: `Ruby` `Rails` `Docker` 查看版本 ```shell! $ docker -v ``` ## Image 映像檔 (read only) -> image + image 可被建立,但不能被修改 ## Container 容器 (內容可以修改) - start - stop - rm 內部,外部 volumn <-- mount /mnt/c/ container = image.new >[alpine](https://hub.docker.com/_/alpine) 迷你版linux ```shell $ docker run alpine ```` :::info 記得要開鯨魚喔~~ 不然會連不上 會docker就有飯吃了 TAT ::: ```shell! $ docker run alpine unamex ``` ```shell! # 列出所有image $ docker image ls # 列出所有在執行的container $ docker container ls # 列出所有的container,包括沒在執行 $ docker container ls -a ``` ``` shell! $ docker run --interactive --tty alpine sh # 工程師的特質 $ docker run -it alpine sh ``` interactive: 我要跟你互動 tty:輸出到外面 就算你刪掉或建立裡面的東西,當你離開,再打開後還會是全新的~ 撿回停止的container: ```shell! docker container start -i -a 123456 ``` -v 把外面某個目錄對應到內部的目錄 **可以看回放喔~大概在11:28開始~** ## Docker file 不想寫又臭又長的指令 所以可以建立一個docker file,連續幫你執行一連串的指令 ```dockerfile! FORM ruby:3.1.2-alpine WORKDIR /prohect COPY Gemfile Gemfile RUN bundle install ``` COPY Gemfile Gemfile => 複製一份Gemfile到container裡~ ## Docker compose 去新公司 下這個指令後環境就設定好了 可以專心寫rails 所以環境不用自己寫,交給公司的前輩大大們~~ ```shell! $ docker compose up ``` :::info 題外話: 問面試官問題 開發環境是用什麼呢?請問開發流程中是使用docker或其他類似的工具嗎? ::: 重點 Image container ***~~Finish~~*** ## Heroku 部署 >:rocket:第五支影片 :::info 2022/Nov.28 起要付費 heroku用小時計費 demo前開付費方案 一天NTD 10 ::: 首先,先註冊帳號啊!!! 如果有就不用。 >CLI: command line interface [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli) ```shell= brew tap heroku/brew && brew install heroku ``` --- >版本確認 ```shell! heroku --version ``` >:bulb:checkpoint: 會顯示:`heroku/7.62.0 darwin-x64 node-v14.19.0` --- >在專案的terminal輸入以下 ```shell= $ heroku login ``` >:bulb:checkpoint: ![](https://i.imgur.com/9K5sDxx.png) --- >開專案+遠端節點 ```shell= $ heroku create [name] ``` >:bulb:checkpoint: 已經贈送網址!只差push上去 ![](https://i.imgur.com/9o7Uk7f.png) --- ```shell= $ git remote -v ``` ![](https://i.imgur.com/a3x3fJP.png) >先git add/ git commit 只有main有作用 其他分支無作用 ```shell= $ git push heroku main ``` ```shell= bundle lock --add-platform x86_64-linux ``` 但現在 push 會壞掉~因為heroku不支援sqlite 所以要換另外一個資料庫-->:bulb:[改資料庫](https://ithelp.ithome.com.tw/articles/10196250) >把這次的 commit 併在上一次的 commit ```shell! $ git commit --amend ``` 部屬後 css 跑掉(沒tailwind)解法: application.html.erb 裡面增加 ```htmlmixed <%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> ``` ### purgecss 可以處理css上線後的內容,只留有用到的tailwind css 減輕容量,加速載入頁面的使用經驗 串金流的環境變數,可以到 heroku 的後台去設定。 ***~~Finish~~*** ## Rails 7 時代 - rails 7 沒有node module沒有yarn add, 裝套件使用importmap - 內建foreman - 內建預設支援tailwind 3 - 內建stimlus - CRUD的destroy, method: delete => data: { turbo-method: :delete } - - `<%= link_to "Destroy", book, data: { turbo_method: :delete, turbo_confirm: "Are you sure?" } %>` - :arrow_up: [RAILS GUIDES](https://guides.rubyonrails.org/layouts_and_rendering.html#rendering-by-default-convention-over-configuration-in-action) - `<%= button_to 'Destroy this book', book_path(@book), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>` - :arrow_up: generated by scaffold > 檢查相容性 [Can I use](https://caniuse.com) 透過importmap引入套件: ```shell bin/importmap pin 套件 bin/importmap unpin 套件 ``` turbolinks => turbodrive - 不只聽連結,連表單也會聽 ### HOTWire (HTML over the wire) Modal可以透過 action cable 或 websocket 來傳遞 html 按下去再跟後端要 . . . . . . (爆米花準備好) 老師表演 rails 7 CRUD 15:50 ```ruby method: "delete" => data: {"turbo_method": "delete"} ``` #### turbo_drive > #### turbo_frame >inline editing在線編輯 #### turbo_stream >可以做到不用js就寫好前端 ***~~Finish~~*** **各位專案加油!!!!!!**

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully