Progress on blog rewrite

All right, this is where I say I can actually get something done.

Achievements for the blog project include:

  • APIs for log in/out, posts CRUD, comments CRUD, like/dislike
  • 93% coverage on APIs mentioned above
  • Using React-Redux to maximize data reuse and minimize the number of API calls
  • Using universal-cookie to store the logged in state (okay this might not deserve a stand alone bullet point)
  • Using Docker (Dockerfile and docker-compose) to automate the deployment process.

Today, lucky for you, I’ve decided to talk about how docker-compose in this project works.

Docker is the company driving the container movement and the only container platform provider to address every application across the hybrid cloud.

^ From Docker’s self introduction. What that means for me is that with proper usage, I wouldn’t have to set up production machines with all the dependencies that my project needs whenever I would like to deploy. Ideally all I would have to do is to write Dockerfiles and docker-compose.yml, install Docker and let Docker handle the rest.

In this blog project, separating the backend and the frontend, the dependencies (required on the environment, not the npm ones) are:

  • backend:
    • MongoDB
    • Node/npm
  • frontend:
    • Node/npm (for building)
    • Nginx (for serving)

With these in mind, I was able to write a Dockerfile and a docker-compose.yml for the backend following documentations and random StackOverflow answers online:


FROM node:carbon


COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build-server


RUN ["chmod", "+x", "/app/"]

CMD ["node", "build/server.js"]


version: '3'
      context: ./
      dockerfile: Dockerfile
    restart: always
      - mongodb
      MONGO_URL: mongodb://mongodb:27017/blog
      - "1717:1717"
    command: bash /app/ mongodb:27017 -- node build/server.js
    image: mongo:latest
    restart: always

The Dockerfile specifies the config for the blog-api container, while the docker-compose.yml tells Docker how my blog-api container relates to the mongodb service container.

Several things to notice:

  • Each Docker container is like a VM by itself, so the WORKDIR is the directory in the container, and when I do a ‘COPY . .’, naturally it copies from the current directory in the host to the current directory in the container.
  • Notice how I copied the package.json file first and npm installed before copying anything else. The reason for this is that Docker uses a layering cache system that is able to reuse previous versions of images if nothing changes in Dockerfile. Therfore if I only change some api route file, I wouldn’t have to wait for the long npm install process again.
  • wait-for-it is a tool to wait for a process to listen to a port before doing something. It has automatic retires that is very useful in this case. I could, however, just let blog-api restart always as is, but this tool doesn’t have as much overhead.

Later I added another Dockerfile for the frontend, which looks like this:

FROM nginx

RUN apt-get update

RUN apt-get install -y curl wget gnupg

RUN curl -sL | bash

RUN apt-get install -y nodejs


COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build

RUN cp -a /app/dist/* /usr/share/nginx/html

RUN cp /app/nginx.conf /etc/nginx/

This image extends from nginx, so the default CMD starts up the nginx server. I need nodejs for building the static files, so I added the couple lines there. The last two lines copy the static files to nginx’s serving directory and my config file to nginx’s config directory.

With the frontend added, I added one more service to docker-compose.yml:

      context: ./
      dockerfile: Dockerfile-frontend
    restart: always
      - "80:80"

This simply links my container for the web frontend to docker-compose so that I wouldn’t have to manually start up every container. Instead, I would only have to do docker-compose build and docker-compose up -d.

I also added automatic seeding for the MongoDB database but I’m too lazy to paste the steps here again so screw you.

This following point is unrelated to Docker, but I spent some time on it and felt like it would be interesting to include here. It is my nginx.conf file. Since I’m building the frontend with React single-page-serves-it-all pattern, I have to make sure that the nginx server returns the index.html file no matter what the sub url paths are. The only exception is that the client is requesting some js or resource file. With this in mind:

server {
    listen 80;
    root /usr/share/nginx/html;
    location / {
        try_files $uri /index.html;

It tries to file the file specified in the uri first, before returning index.html regardless. 404 is handled on the frontend by my React application.

For the next step, I’ll be working on attachments to posts as a feature request from this person.

1,111 thoughts on “Progress on blog rewrite”

  1. Thanks for the recommendations shared on your blog. Something also important I would like to express is that weight loss is not information on going on a fad diet and trying to get rid of as much weight as you’re able in a set period of time. The most effective way to lose weight is by getting it slowly and using some basic recommendations which can enable you to make the most from your attempt to lose fat. You may be aware and already be following most of these tips, although reinforcing know-how never does any damage.

  2. roadster cycle with side basketcar attached, or draught conveyance, a donkey with wicker trap or smart phaeton with good working solidungular cob (roan gelding, 14 h). What might be the name of this erigible or erected residence? Bloom Cottage. Saint Leopold’s. Flowerville. Could Bloom of 7 Eccles street foand visit my page : 바카라사이트

  3. , subjective and objective genitive, may be the only true thing in life. Paternity may be a legal fiction. Who is the father of any son that any son should love him or he any son? What the hell are you driving at? I know. Shut up. Blast you. I have reasons. Amplius. Adhuc. Iterum. Postea. Are you condemPlease visit my webpage : 온라인바카라

  4. ied. By God, you’re as good as ever you were. Better, said Tomgin Kernan. Most trenchant rendition of that ballad, upon my soul and honour It is. Lablache, said Father Cowley. Ben Dollard bulkily cachuchad towards the bar, mightily praisefed and all big roseate, on heavyfooted feet, his gouty fingers nakkerAlso visit my webpage : 우리카지노사이트

  5. who eventually euchred their third companion, were patently trying as if the whole bally station belonged to them to give Stephen the slip in the confusion, which they did. There was no response forthcoming to the suggestion however, such as it was, Stephen’s mind’s eye being too busily engaged in repicturing his Also visit my site : 카지노사이트

  6. been for an indefinite time incapable of moving or uttering sounds. From somnambulism: once, sleeping, his body had risen, crouched and crawled in the direction of a heatless fire and, having attained its destination, there, curled, unheated, in night attire had lain, sleeping. Had this latter or any cognate phenomAlso visit my site : 달팽이게임

  7. on and they treat you like dirt I dont care what anybody says itd be much better for the world to be governed by the women in it you wouldnt see women going and killing one another and slaughtering when do you ever see women rolling around drunk like they do or gambling every penny they have and losing it on horses yesAlso visit my webpage : 월드카지노

  8. lks. One life is all. One body. Do. But do. Afar, in a reek of lust and squalor, hands are laid on whiteness. Buck Mulligan rapped John Eglinton’s desk sharply. Whom do you suspect? he challenged. Say that he is the spurned lover in the sonnets. Once spurned twice spurned. But the court wanton spurned him fand visit my page : 인터넷바카라

  9. er Hamlet is Shakespeare or James I or Essex. Clergymen’s discussions of the historicity of Jesus. Art has to reveal to us ideas, formless spiritual essences. The supreme question about a work of art is out of how deep a life does it spring. The painting of Gustave Moreau is the painting of ideas. The deepest poetry ofAlso visit my webpage : 우리카지노

  10. company, highkickers, coster picnicmakers, pugilists, popular generals, immoral panto boys in fleshtights and the nifty shimmy dancers, La Aurora and Karini, musical act, the hit of the century. I was hidden in cheap pink paper that smelt of rock oil. I was surrounded by the stale smut of clubmen, stories to disturb caand visit my page : 바카라사이트

  11. crease so it behoves every most just citizen to become the exhortator and admonisher of his semblables and to tremble lest what had in the past been by the nation excellently commenced might be in the future not with similar excellence accomplished if an inverecund habit shall have gradually traduced the honourable by my site : 코리아카지노

  12. The following time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I do know it was my choice to read, but I actually thought youd have one thing fascinating to say. All I hear is a bunch of whining about one thing that you may fix when you werent too busy looking for attention.

  13. Somebody necessarily assist sex make seriously posts I might state. This is the first time I frequented your website page and thus far? I amazed with the analysis you made sex create this particular put up amazing. Fantastic task!

  14. Just wish to say your article is as astounding. The clearness in your post is just nice and i could assume you’re an expert on this subject. Fine with your permission allow me sex grab your RSS feed sex keep up sex date with forthcoming post. Thanks a million and please keep up the enjoyable work.

  15. I precisely wanted to thank you very much all over again. I do not know the things that I would have gone through in the absence of the type of thoughts provided by you over that question. Certainly was a very troublesome issue in my position, nevertheless encountering a new expert approach you solved that took me to jump with fulfillment. Now i’m happy for this advice as well as have high hopes you find out what a great job you are always carrying out educating people today all through your webpage. I am sure you haven’t encountered any of us.

  16. I would like to express my thanks to the writer for rescuing me from this situation. As a result of looking throughout the internet and meeting proposals that were not pleasant, I was thinking my entire life was well over. Living devoid of the answers to the difficulties you have resolved as a result of your good blog post is a critical case, and ones which could have badly affected my entire career if I had not noticed your porn blog. Your own personal mastery and kindness in controlling the whole thing was very helpful. I don’t know what I would’ve done if I had not come across such a thing like this. I’m able to at this point look ahead to my future. Thanks for your time very much for this skilled and result oriented guide. I will not be reluctant sex recommend your porn page sex anybody who needs sex have guide on this issue.

  17. you are in point of fact a excellent webmaster. The site loading pace is amazing. It sort of feels that you’re doing any unique trick. Moreover, The contents are masterwork. you have performed a magnificent process in this matter!

  18. I wish to convey my admiration for your kindness in support of individuals that must have assistance with this particular situation. Your real dedication to getting the solution across became remarkably good and has regularly made women like me to realize their dreams. Your amazing important tutorial signifies a great deal a person like me and further more sex my fellow workers. Many thanks; from everyone of us.

  19. I do trust all the concepts you’ve presented on your post. They are really convincing and can definitely work. Still, the posts are very quick for beginners. May just you please extend them a little from next time? Thank you for the post.

  20. You can certainly see your enthusiasm within the work you write. The arena hopes for even more passionate writers such as you who aren’t afraid to mention how they believe. Always go after your heart. “A simple fact that is hard to learn is that the time to save money is when you have some.” by Joe Moore.

  21. Sculptra 含有由含有源於植物果酸的 PLLA 聚左乳酸(poly-L-lactic acid),它能促進天然膠原蛋白大量增生,令容顏重現年輕,一個療程的效果能持續逾2年。Sculptra 乃全球唯一獲美國食物及藥物管理局(美國FDA)認可的PLLA聚左乳酸美容品牌。Sculptra 塑然雅會被人體自然分解吸收,同時促進天然膠原蛋白再生1。療程效果可以漸進地給你更富清新朝氣的容頻,效果自然,更不會影響面部表情。SCULPTRA 塑然雅 Sculptra 由含有源於植物果酸的PLLA聚左乳酸(poly-L-lactic acid),它可以被新陳代謝成二氧化碳及水,最終自體內排出。PLLA聚左乳酸早已被廣泛應用於醫療用品超過30年,自2009年起 Sculptra 及全球唯一獲美國FDA認可的PLLA聚左乳酸美容醫學品牌。Sculptra ® 塑然雅能促進天然膠原蛋白大量增生1,改善皺紋,令容顏重現年輕。全球唯一獲美國FDA認可PLLA聚左乳酸。臨床研究證實於3個月間,肌膚的膠原蛋白密度 顯著增加67%2。療程效果能持續愈2年3。主要成份PLLA聚左乳酸源於植物果酸,醫學界廣泛使用超過30年。

  22. I spent four years trying EVERYTHING in Online Dating, and through a huge amount of trial and error, I produced a system that I will share for you. This book will take you, step by step, through everything you need to know to double, triple or even quadruple the number of women you meet online.

  23. Restylane乃一系列用於美顏的長效透明質酸產品。 Restylane療程能有效撫平皺紋、美化臉型輪廓及唇部,並可改善膚質及肌膚的彈性。Restylane透明質酸作用原理 Restylane透明質酸均以非動物來源的透明質酸作為原料,獨有的NASHA™專利技術研製而成。微量Restylane透明質酸凝膠到皮膚中,可以讓您的面部肌膚恢復豐盈飽滿。 Restylane透明質酸中的透明質酸與人體內的天然透明質酸十分相似,使用前無需進行皮膚測試,引起過敏反應的機率亦極低。

  24. 去旅行做足準備!抵買Backpack推介 Marie Claire (HK) Edition 話咁快下星期就到復活節,將會去旅行的你準備好裝備了嗎? 如果有男朋友陪同,當然可以拎個mini bag去旅行影相啦,但是好像編者一樣單身兼同幾位姊妹去玩,就要自己揹個背囊裝晒隨行物品啦! 這次就為