|
| 1 | +--- |
| 2 | +title: Dockerize the Documentation Website and Publish to GitHub |
| 3 | +--- |
| 4 | + |
| 5 | +To dockerize the Thoth Tech Documentation Website and publish it to GitHub packages, the following |
| 6 | +steps were followed. |
| 7 | + |
| 8 | +## Create Docker Compose and Dockerfile |
| 9 | + |
| 10 | +1. Fork the [ThothTech Documentation](https://github.com/thoth-tech/ThothTech-Documentation-Website) |
| 11 | + Repo on GitHub. |
| 12 | +2. Open the repository on your local machine using Visual Studio Code. |
| 13 | +3. Locate **View** on the toolbar and select **Command Palette** (this is usually located on the top |
| 14 | + left hand corner of VS Code). |
| 15 | +4. When Command Palette is selected, choose **Docker: Add Docker Files to Workspace**. |
| 16 | +5. In **Select Application Platform**, choose Node.js. |
| 17 | +6. In **Choose a package.json file** select package.json. |
| 18 | +7. Type 4321 as the port that the application/website listens on. |
| 19 | +8. Select **Yes** for **Include Optional Docker Compose Files**. |
| 20 | +9. Press Enter and Dockerfile and Docker Compase would be generated for your environment. |
| 21 | + |
| 22 | +## Generate a Personal Access Token on GitHub |
| 23 | + |
| 24 | +1. Navigate to Thoth Techs GitHub page. |
| 25 | +2. In the upper-right corner of any page, click your profile photo, then click Settings. |
| 26 | +3. In the left sidebar, click Developer settings. |
| 27 | +4. In the left sidebar, under Personal access tokens, click Tokens (classic). |
| 28 | +5. Select Generate new token, then click Generate new token (classic). |
| 29 | +6. In the "Note" field, give your token a descriptive name. |
| 30 | +7. To give your token an expiration, select Expiration, then choose a default option or click Custom |
| 31 | + to enter a date. |
| 32 | +8. Select the scopes you'd like to grant this token. For this implementation write.packages and |
| 33 | + delete.packages was assigned. |
| 34 | +9. Click Generate token. |
| 35 | +10. Copy the new token to your clipboard. |
| 36 | + |
| 37 | +## Build Docker Image and Push to GitHub Container Registry |
| 38 | + |
| 39 | +**NB: For this action you would need Docker Desktop to be installed on your desktop**. |
| 40 | + |
| 41 | +1. Open Docker Desktop on your laptop |
| 42 | +2. On your terminal ensure you are in the directory that has your Dockerfile, run the below command |
| 43 | + |
| 44 | +``` |
| 45 | +docker login --username [Your-GitHub-Name] --password [The generated token] ghcr.io |
| 46 | +``` |
| 47 | + |
| 48 | +3. Build the docker image by running the below command. |
| 49 | + |
| 50 | +``` |
| 51 | +docker build . -t ghcr.io/kachi-okorie/documentationwebsite:latest |
| 52 | +``` |
| 53 | + |
| 54 | +4. Push image to GitHub |
| 55 | + |
| 56 | +``` |
| 57 | +docker push ghcr.io/kachi-okorie/documentationwebsite:latest |
| 58 | +``` |
| 59 | + |
| 60 | +You should now see the docker image being pushed to GitHub package.  |
| 61 | + |
| 62 | +## Test Image Pushed to GitHub |
| 63 | + |
| 64 | +1. Run the below command to obtain the ID of the image running locally on your machine. |
| 65 | +2. Delete local image to ensure your run image from the remote GitHub repository. In the command |
| 66 | + below, **889** is the first 3 digits of my image ID. |
| 67 | + |
| 68 | +``` |
| 69 | +docker image rm 889 --force |
| 70 | +``` |
| 71 | + |
| 72 | +3. Run the below command to run the image remotely. |
| 73 | + |
| 74 | +``` |
| 75 | +docker run ghcr.io/kachi-okorie/documentationwebsite:latest |
| 76 | +``` |
0 commit comments