{
    "componentChunkName": "component---src-templates-article-page-template-js",
    "path": "/ftw/run-ftw-with-docker/",
    "result": {"data":{"markdownRemark":{"frontmatter":{"title":"How to run FTW in a Docker container","slug":"run-ftw-with-docker","updated":"2023-02-20T00:00:00.000Z","category":"ftw-hosting","ingress":"This guide describes how to set up a Docker container running the FTW template.","skills":null},"htmlAst":{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Depending on your deployment infrastructure, you may want to run your\nFTW-based marketplace application in a Docker container. This article\nfeatures a sample Dockerfile you can use to create your Docker image."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"info","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To learn more about Docker and its key concepts, check out\n"},{"type":"element","tagName":"a","properties":{"href":"https://docs.docker.com/","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"Docker documentation"}]},{"type":"text","value":" or watch a\n"},{"type":"element","tagName":"a","properties":{"href":"https://youtu.be/pTFZFxd4hOI","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"Docker introduction video"}]},{"type":"text","value":". This guide\nassumes you have Docker installed and running on your development\nmachine."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To run your FTW app with Docker, you will need to"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"add your Dockerfile"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"build the Docker image, and"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"run the Docker container."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"add-your-dockerfile","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#add-your-dockerfile","ariaLabel":"add your dockerfile permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Add your Dockerfile"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For creating a Docker image of your FTW, you will need to add a\nDockerfile. Add a file titled "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Dockerfile"}]},{"type":"text","value":" with no file extension to the\nroot of your FTW folder, on the same level as your "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"package.json"}]},{"type":"text","value":" file.\nCopy the following contents, paste them to the newly created\n"},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Dockerfile"}]},{"type":"text","value":" and save."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"FROM node:16\nWORKDIR /home/node/app\nCOPY package.json ./\nCOPY yarn.lock ./\nRUN yarn install\nCOPY . .\nENV PORT=4000\nENV NODE_ENV=production\nEXPOSE 4000\nRUN yarn run build\nUSER node\nCMD [\"yarn\", \"start\"]"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In addition, you need to add a "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":".dockerignore"}]},{"type":"text","value":" file in the same root\nfolder. Copy the following contents, paste them to the newly created\n."},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"dockerignore"}]},{"type":"text","value":" file, and save."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"# Ignore node_modules because they get installed in the Dockerfile.\nnode_modules"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"build-your-docker-image-and-run-the-docker-container","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#build-your-docker-image-and-run-the-docker-container","ariaLabel":"build your docker image and run the docker container permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Build your Docker image and run the Docker container"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To build your Docker image, open your command line and navigate to the\nroot of your FTW folder. Run the following command – be careful to\ninclude the final "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"."}]},{"type":"text","value":" , as it indicates that the Dockerfile is in the\ncurrent directory."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"shell"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-shell"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"$ "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"docker"}]},{"type":"text","value":" build -t ftw-docker "},{"type":"element","tagName":"span","properties":{"className":["token","builtin","class-name"]},"children":[{"type":"text","value":"."}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The build step can take a while. After the build step completes, you can\nstart a container using the image you created."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"shell"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-shell"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"$ "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"docker"}]},{"type":"text","value":" run -dp "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"4000"}]},{"type":"text","value":":4000 ftw-docker"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can now visit "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"http://localhost:4000","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"http://localhost:4000"}]}]},{"type":"text","value":" on your local machine to see\nthat the container is running your application."}]}],"data":{"quirksMode":false}},"headings":[{"value":"Add your Dockerfile","depth":2},{"value":"Build your Docker image and run the Docker container","depth":2}]}},"pageContext":{"slug":"run-ftw-with-docker","category":"ftw-hosting"}},
    "staticQueryHashes": ["3794076007","439097193","717698143"]}