[{"data":1,"prerenderedAt":103},["ShallowReactive",2],{"\u002Ftlt-2018.02.05-oddmuse-wiki-dockerized":3},{"id":4,"title":5,"body":6,"createdAt":89,"description":90,"draft":91,"extension":92,"image":93,"mastodonThread":93,"meta":94,"navigation":95,"path":96,"seo":97,"stem":98,"tags":99,"updatedAt":101,"__hash__":102},"content\u002FTLT - 2018.02.05 - OddMuse Wiki Dockerized.md","TLT_-_2018.02.05_-_OddMuse_Wiki_Dockerized",{"type":7,"value":8,"toc":86},"minimark",[9,21,30,41,48,51,59,65,74,83],[10,11,12,13,20],"p",{},"I Dockerized this website yesterday! I had already built a ",[14,15,19],"a",{"href":16,"rel":17},"https:\u002F\u002Fthelackthereof.org\u002Fcpanfile",[18],"nofollow","cpanfile"," that declares the Perl5 dependencies of OddMuse, which made it easy. I'm also going to run this with the data directory directly bind-mounted.",[10,22,23,24,29],{},"First the ",[14,25,28],{"href":26,"rel":27},"https:\u002F\u002Fthelackthereof.org\u002FDockerfile",[18],"Dockerfile",":",[31,32,37],"pre",{"className":33,"code":35,"language":36},[34],"language-text","FROM perl:latest\n\n# Set up the deploy user\nARG uid=1000\nARG gid=1000\nRUN echo groupadd -g $gid deploy\nRUN groupadd -g $gid deploy\nRUN useradd --create-home -u $uid -g $gid -ms \u002Fbin\u002Fbash deploy\n\nWORKDIR \u002Fapp\n\nCOPY cpanfile .\nRUN cpanm -qn --installdeps .\n\nUSER deploy\n","text",[38,39,35],"code",{"__ignoreMap":40},"",[10,42,43,44,47],{},"The bit of fancyness here is the deploy user setup. Since I'm mounting the project directory for data files, I'd like new files and edits to be done by my normal user. On my cloud-server, this is uid 1000, which is easy to set as the default. On my laptop I run as user 1001, so the file is parameterized for this case. When I run locally, I have to build my docker image with ",[38,45,46],{},"docker build --build-arg uid=$(id -u) --build-arg gid=$(id -g)",". Not as much fun.",[10,49,50],{},"Otherwise, this starts with the Perl5 base image and installs the CPAN dependencies.",[10,52,53,54],{},"Next, the ",[14,55,58],{"href":56,"rel":57},"https:\u002F\u002Fthelackthereof.org\u002Fdocker-compose.yml",[18],"docker-compose.yml",[31,60,63],{"className":61,"code":62,"language":36},[34],"version: '3'\n\nservices:\n\n  web:\n    build: .\n    command: starman --workers=10 --max-requests=1 --access-log starman-access.log --error-log starman-error.log oddmuse.psgi\n    volumes:\n      - \".:\u002Fapp\"\n    ports:\n      - \"5000\" # For running locally\n\n  nginx-ssl-proxy:\n    image: danieldent\u002Fnginx-ssl-proxy\n    restart: always\n    environment:\n      UPSTREAM: web:5000\n      SERVERNAME: thelackthereof.org\n      EXTRANAMES: www.thelackthereof.org\n    ports:\n      - \"80:80\"\n      - \"443:443\"\n    volumes:\n      - \"\u002Fetc\u002Fletsencrypt\"\n    depends_on:\n      - web\n",[38,64,62],{"__ignoreMap":40},[10,66,67,68,73],{},"The first service runs cpan:Starman (this is similar to Unicorn for you Ruby folk). It mounts the project directory as \u002Fapp, and runs ",[14,69,72],{"href":70,"rel":71},"https:\u002F\u002Fthelackthereof.org\u002Foddmuse.psgi",[18],"oddmuse.psgi",". We declare port 5000 anyway for local debugging -- we can then run only this service and it'll come up on a randomly assigned port that connects to port 5000. Other services on this network can connect to \"web:5000\" even without this declaration.",[10,75,76,77,82],{},"Which brings us to the second fancy bit. The ",[14,78,81],{"href":79,"rel":80},"https:\u002F\u002Fgithub.com\u002FDanielDent\u002Fdocker-nginx-ssl-proxy",[18],"danieldent\u002Fnginx-ssl-proxy"," image is a super cool image that gives an nginx proxy with automatic letsencrypt setup! You declare the domain name and the proxy destination (web:5000 is our Starman), and assuming that domain really is pointing here, it will work with letsencrypt to verify ownership and make certificates. The certs are stored in a docker-managed volume, and are periodically renewed. This takes less than a minute, so even if the volume gets accidentally deleted we can easily get a new cert.",[10,84,85],{},"Now running \"docker-compose up -d\" starts nginx and starman running in the background. All that remains is getting this running on boot. Since the startup command can be run over and over, worst case you can put it in a cronjob that runs frequently :)",{"title":40,"searchDepth":87,"depth":87,"links":88},2,[],"2018-02-05T07:50-05:00","I Dockerized this website yesterday! I had already built a cpanfile that declares the Perl5 dependencies of OddMuse, which made it easy. I'm also going to run this with the data directory directly bind-mounted.",false,"md",null,{},true,"\u002Ftlt-2018.02.05-oddmuse-wiki-dockerized",{"title":5,"description":90},"TLT - 2018.02.05 - OddMuse Wiki Dockerized",[100],"blog","2018-02-05T08:14-05:00","aWuAfq9msEQqxJ2CHjxp4moaMwioutmXWgqJE0uvTUw",1778988314623]