This document explains the setup procedure for automatically deploying Docker containers with GitHub Actions.

Table of Contents

  1. Docker Configuration
  2. GitHub Actions Configuration
  3. Server-Side Configuration
  4. Troubleshooting

Docker Configuration

Dockerfile (Static Site + nginx)

Generates static HTML and serves it with nginx.

FWCRCR#F##CCECROOUOUROOXMORPNPNnOFFPPPDMKYYgMooYYODnnirrS[nIpp.pnnnE"oRammxgNN-gndciuufi8ge/kirfnxxrn0i:aanuoxttoxn2pgsnr:m.x2peta32=c"-*agsl::bo,a.leepunljlnridif"psevnoil-iorieusd/gnnanttee"etgprt,eucAst//"St/andappgabtupieuib/nmicl.xolio/ndfcuceitoorlpnfeuffst.;d"p/]udbelfiacul/tu.scrnsfhare/nginx/html

nginx.conf (SPA Configuration)

For SPAs, dynamic routes (/item/:id, etc.) need to fall back to index.html.

s}ervelsri#gg#l}#l}rieonzzoosrodgiiScSc{tvtezppPataeexi_Attateanr/pot:irtixd_uinyoyiopd8nsnc;pfn_cni_0ardoeafrh;m/emsl/if~eeesxplli*sah.rtb{eldlaheease1eortsxcyrcemstk$c(;a/li/uajCln;opnrcsahgnloih|coianichsni-$nsetxneugs-;/xr|Chtiipotes/nnmxtgtlte/|r;/nijoctnplsdgspe|"axjpat.puphhebpstgllm|iitlgcco;i,afti|iinimodcmneou/x|tj.sashvbotglnm|elw"ao;pfpfl|iwcoaftfi2o)n$/j{avascripttext/xmlapplication/xmlapplication/xml+rsstext/javascript;

docker-compose-prod.yml (Traefik Integration)

sneercttvjwri_blnrpoaecfuaeeorexericbttttttt-sr-kftsoloerrrrrrwttsie:ndnlaaaaaaotas":krt:tseeeeeerrr:8-n:e:ffffffkat0naxiiiiiise:0eltkkkkkk:f3t::......ia:wehhhhhkl8ot.nttttt-w0rratttttna"kubpppppey:el.....tserrrrmw:ooooiouuuudrtttttdkreeeelurrrreessssw....accccrjjjje____sffff.rrrrgooooznnnnittttp....-retmcunlioltsdmer.dp:yclrpeeeHorwsoitassnrr.tteec(ssso`:o:mylpowvgrueezerbris-s:psde-:ocmcmuyotarrmrieepunsre.oeclsovsme`r)

GitHub Actions Configuration

.github/workflows/prod.yml

nocjanoom:pwrngcbbeuoecrasu:sbrptuon:irshrkoyruclutp:afsprpedne-rnliee:l_spocotsn-a-snuwdhwo:c'ino:asie_rypndnmethukpssdy[:a-_:eshoseoc:i_wgpd:::seyrrscgddddsdeereutr:tiedioooo[pibsopbDa:n:pttcccc'ash'gluepa$t/kkkkmtporonpp$m{$:-hpeeeeacaoeytll{e{{eourrrrshtks:uoe{:{|mlt:c]s-ybselcccseh:los$es/oooyr:aDye{ce$mmms'tto/c{rc{pppt]recsrer{oooeusksestesssmetehtestseeer-sc.sepa.rR.c---rCcReERrfffuotEtMEenniMsOMtdddetoO.TOsoooanTRET.ccc-i@EE_ERkkkanm_MK_EeeeeaHOEPMrrrrsOTYOO---tSERTccceT_}TEoooorU}_mmml}S}Upppu}E}SooomREssseReees}---}}ppp-}rrrf/ooocdddj..._yyyfmmmrlllonbdutuopiwln-dd

Registering GitHub Secrets

Register using GitHub CLI:

gggghhhhsssseeeeccccrrrreeeettttsssseeeettttRRRREEEEMMMMOOOOTTTTEEEE____HUPKOSOESERYTRT<---~bbboo.dddsyyysh"""/xu2yxs2oxe"u.rrxn_xakxme.eyx"/xixd._xrxsxa"

Or from the GitHub Web UI: Settings -> Secrets and variables -> Actions -> New repository secret

Secret NameDescription
REMOTE_HOSTServer IP address
REMOTE_USERSSH username
REMOTE_KEYSSH private key (full text)
REMOTE_PORTSSH port (usually 22)

Server-Side Configuration

1. Clone the Repository

cgdit/hcolmoen/eusgeirtn@agmiethub.com:your-org/your-repo.gitcj_front

2. Set Remote URL to SSH Format

HTTPS format causes authentication errors when git pull is run from GitHub Actions.

cgdit/hroemmetuesesrenta-muer/lcjo_rfirgoinntgit@github.com:your-org/your-repo.git

3. Add GitHub’s Host Key

ssh-keyscangithub.com~/.ssh/known_hosts

4. Register SSH Public Key with GitHub

Check the server’s public key:

cat~/.ssh/id_rsa.pub

If no key exists, generate one:

ssh-keygen-trsa-b4096-C"your-email@example.com"

Register the public key with GitHub:

  • Account level (recommended): GitHub -> Settings -> SSH and GPG keys -> New SSH key
  • Repository level: Repository -> Settings -> Deploy keys -> Add deploy key

Note: The same SSH key can only be registered for one repository or one account on GitHub. If you need to use it across multiple repositories, register it at the account level.

5. Creating docker-compose-prod.yml

s}ervelsri#gg#l}#l}rieonzzoosrodgiiScSc{tvtezppPataeexi_Attateanr/pot:irtixd_uinyoyiopd8nsnc;pfn_cni_0ardoeafrh;m/emsl/if~eeesxplli*sah.rtb{eldlaheease1eortsxcyrcemstk$c(;a/li/uajCln;opnrcsahgnloih|coianichsni-$nsetxneugs-;/xr|Chtiipotes/nnmxtgtlte/|r;/nijoctnplsdgspe|"axjpat.puphhebpstgllm|iitlgcco;i,afti|iinimodcmneou/x|tj.sashvbotglnm|elw"ao;pfpfl|iwcoaftfi2o)n$/j{avascripttext/xmlapplication/xmlapplication/xml+rsstext/javascript;

0


Troubleshooting

nginx 404 Error (SPA)

If you get a 404 when accessing dynamic routes (/item/:id), add the following to nginx.conf:

s}ervelsri#gg#l}#l}rieonzzoosrodgiiScSc{tvtezppPataeexi_Attateanr/pot:irtixd_uinyoyiopd8nsnc;pfn_cni_0ardoeafrh;m/emsl/if~eeesxplli*sah.rtb{eldlaheease1eortsxcyrcemstk$c(;a/li/uajCln;opnrcsahgnloih|coianichsni-$nsetxneugs-;/xr|Chtiipotes/nnmxtgtlte/|r;/nijoctnplsdgspe|"axjpat.puphhebpstgllm|iitlgcco;i,afti|iinimodcmneou/x|tj.sashvbotglnm|elw"ao;pfpfl|iwcoaftfi2o)n$/j{avascripttext/xmlapplication/xmlapplication/xml+rsstext/javascript;

1

git pull Error in GitHub Actions

Error: fatal: could not read Username for 'https://github.com' Cause: Repository was cloned in HTTPS format Solution: Change to SSH format

s}ervelsri#gg#l}#l}rieonzzoosrodgiiScSc{tvtezppPataeexi_Attateanr/pot:irtixd_uinyoyiopd8nsnc;pfn_cni_0ardoeafrh;m/emsl/if~eeesxplli*sah.rtb{eldlaheease1eortsxcyrcemstk$c(;a/li/uajCln;opnrcsahgnloih|coianichsni-$nsetxneugs-;/xr|Chtiipotes/nnmxtgtlte/|r;/nijoctnplsdgspe|"axjpat.puphhebpstgllm|iitlgcco;i,afti|iinimodcmneou/x|tj.sashvbotglnm|elw"ao;pfpfl|iwcoaftfi2o)n$/j{avascripttext/xmlapplication/xmlapplication/xml+rsstext/javascript;

2

Error: Host key verification failed Solution: Add GitHub’s host key

s}ervelsri#gg#l}#l}rieonzzoosrodgiiScSc{tvtezppPataeexi_Attateanr/pot:irtixd_uinyoyiopd8nsnc;pfn_cni_0ardoeafrh;m/emsl/if~eeesxplli*sah.rtb{eldlaheease1eortsxcyrcemstk$c(;a/li/uajCln;opnrcsahgnloih|coianichsni-$nsetxneugs-;/xr|Chtiipotes/nnmxtgtlte/|r;/nijoctnplsdgspe|"axjpat.puphhebpstgllm|iitlgcco;i,afti|iinimodcmneou/x|tj.sashvbotglnm|elw"ao;pfpfl|iwcoaftfi2o)n$/j{avascripttext/xmlapplication/xmlapplication/xml+rsstext/javascript;

3

Error: Permission denied (publickey) Solution: Register the server’s SSH public key with GitHub


References