Skip to content

Commit 0c5d635

Browse files
committed
deployment section done
1 parent 24ad615 commit 0c5d635

File tree

2 files changed

+125
-1
lines changed

2 files changed

+125
-1
lines changed

README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,130 @@ yarn start
9999

100100
## Deployment
101101

102+
There are three deployment methods available locally and in Github Actions. You can always easily identify currently deployed version by checking **the latest commit info in the footer** of the deployed website.
103+
104+
For Github Actions workflows you will need to set these secrets in your Github repository settings:
105+
106+
```bash
107+
# Dockerhub user and pass
108+
DOCKER_PASSWORD
109+
DOCKER_USERNAME
110+
111+
# remote server ssh credentials
112+
REMOTE_HOST
113+
REMOTE_KEY_ED25519
114+
REMOTE_PORT
115+
REMOTE_USERNAME
116+
```
117+
118+
### 1. Nginx
119+
120+
All Nginx deployments come down to building the website and copying the compiled files from the `/dist` folder into the Nginx web root folder on a remote server.
121+
122+
#### Local
123+
124+
```bash
125+
# package.json
126+
127+
# set your SITE_URL
128+
"build:nginx": "SITE_URL='https://nemanjamitic.com' astro build",
129+
130+
# build the app
131+
yarn build:nginx
132+
133+
# configure ssh for your own "arm1" remote server in /home/username/.ssh/config
134+
135+
# copy compiled app from local /dist folder to Nginx web root on the remote server
136+
"deploy:nginx": "bash scripts/deploy-nginx.sh '~/traefik-proxy/apps/nmc-nginx-with-volume/website' arm1",
137+
```
138+
139+
#### Github Actions
140+
141+
Just trigger one of the following workflows:
142+
143+
```bash
144+
# .github/workflows/bash__deploy-nginx.yml
145+
146+
# .github/workflows/default__deploy-nginx.yml
147+
```
148+
149+
SSH alias for the remote server, example config file:
150+
151+
```bash
152+
# /home/username/.ssh/config
153+
154+
# arm1 ssh alias for remote server
155+
Host arm1 123.123.13.123
156+
HostName 123.123.13.123
157+
IdentityFile ~/.ssh/my-servers/arm1-ssh-private-key.key
158+
User your-user
159+
```
160+
161+
### 2. Github Pages
162+
163+
Only available in Github Actions. Just trigger one of the following workflows:
164+
165+
```bash
166+
# uses official Astro action
167+
# .github/workflows/gh-pages__deploy-astro.yml
168+
169+
# uses manual build, useful for Astro in monorepos
170+
# .github/workflows/gh-pages__deploy-manual.yml
171+
```
172+
173+
### 3. Docker
174+
175+
#### Local
176+
177+
To build `linux/arm64` Docker images locally if you have x86 computer you will need to install Qemu and Buildx locally, see this tutorial:
178+
179+
[Multi-Arch Images with Docker Buildx and QEMU](https://drpdishant.medium.com/multi-arch-images-with-docker-buildx-and-qemu-141e0b6161e7)
180+
181+
If you are on Ubuntu you will probably need to run this too.
182+
183+
```bash
184+
# Register QEMU for Docker
185+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
186+
```
187+
188+
After that you can build and push multi-platform images locally.
189+
190+
```bash
191+
# package.json
192+
193+
# open terminal and login with your Dockerhub account, both locally and on remote server
194+
docker login my-user my-pass
195+
196+
# replace "nemanjamitic/nemanjam.github.io" with your image name
197+
# set ARG_SITE_URL to your production url
198+
# set correct architecture for your production server --platform linux/arm64 or linux/amd64
199+
"docker:build:push:arm": "docker buildx build -f ./docker/Dockerfile -t nemanjamitic/nemanjam.github.io --build-arg ARG_SITE_URL='https://nmc-docker.arm1.nemanjamitic.com' --platform linux/arm64 --push .",
200+
201+
# build and push Docker image, replace "arm" with your architecture
202+
yarn docker:build:push:arm
203+
204+
# replace "~/traefik-proxy/apps/nmc-docker" with your path to docker-compose.yml
205+
# replace "nemanjamitic/nemanjam.github.io" with your image name
206+
"deploy:docker": "bash scripts/deploy-docker.sh arm1 '~/traefik-proxy/apps/nmc-docker' nemanjamitic/nemanjam.github.io",
207+
208+
# pull and run latest image on your production server
209+
yarn deploy:docker
210+
```
211+
212+
#### Github Actions
213+
214+
Just trigger these workflows:
215+
216+
```bash
217+
# build and push Docker image
218+
# .github/workflows/default__build-push-docker.yml
219+
220+
# pull and run latest Docker image
221+
# trigger one of the following:
222+
# .github/workflows/bash__deploy-docker.yml
223+
# .github/workflows/default__deploy-docker.yml
224+
```
225+
102226
## Roadmap
103227

104228
- Add accessibility attributes

docs/working-notes/readme-notes/detailed-features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ The greatest care is devoted to a solid, clear, comprehensive, understandable, m
7373

7474
#### Deployment
7575

76-
- Latest git commit info is included in the website footer for easy identification of currently deployed version
76+
- Latest git commit info is included in the website footer for easy identification of the currently deployed version
7777
- Production deployments with Github Pages, Nginx and Docker image
7878
- All three deployment methods are supported both in Github Actions and locally
7979
- The same bash scripts reused for both Github Actions and local deployments for easy debugging locally

0 commit comments

Comments
 (0)