Skip to content

Commit

Permalink
ci: docker config
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Oct 2, 2023
1 parent c1e1521 commit f55f1e5
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 50 deletions.
16 changes: 16 additions & 0 deletions apps/assets/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:18-alpine as runner

WORKDIR /app

ENV PORT 3000
ENV NODE_ENV production

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs

COPY --chown=nodejs:nodejs ./dist/apps/assets ./

USER nodejs
EXPOSE 3000

CMD node main.js
28 changes: 28 additions & 0 deletions apps/assets/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"extractLicenses": true,
"sourceMap": false,
"externalDependencies": "none"
},
"local": {
"optimization": true,
"extractLicenses": true,
"sourceMap": false,
"externalDependencies": "none"
}
}
},
Expand All @@ -39,6 +45,28 @@
}
}
},
"container": {
"executor": "@nx-tools/nx-container:build",
"dependsOn": ["build"],
"defaultConfiguration": "local",
"options": {
"engine": "docker",
"context": "./",
"file": "apps/assets/Dockerfile"
},
"configurations": {
"local": {
"tags": ["siafoundation/web-assets:latest"],
"file": "apps/assets/Dockerfile",
"push": false
},
"production": {
"tags": ["ghcr.io/siafoundation/web-assets:latest"],
"file": "apps/assets/Dockerfile",
"push": true
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
Expand Down
2 changes: 1 addition & 1 deletion apps/assets/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ setupStatic(app)

console.log(`Assets running in ${process.env.NODE_ENV}`)

const port = 3002
const port = process.env.PORT || 3002
const server = app.listen(port, () => {
console.log(`Listening at http://localhost:${port}`)
})
Expand Down
15 changes: 15 additions & 0 deletions apps/crons/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:18-alpine as runner

WORKDIR /app

ENV NODE_ENV production
# requires NOTION_TOKEN

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs

COPY --chown=nodejs:nodejs ./dist/apps/crons ./

USER nodejs

CMD node main.js
28 changes: 28 additions & 0 deletions apps/crons/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"extractLicenses": true,
"sourceMap": false,
"externalDependencies": "none"
},
"local": {
"optimization": true,
"extractLicenses": true,
"sourceMap": false,
"externalDependencies": "none"
}
}
},
Expand All @@ -39,6 +45,28 @@
}
}
},
"container": {
"executor": "@nx-tools/nx-container:build",
"dependsOn": ["build"],
"defaultConfiguration": "local",
"options": {
"engine": "docker",
"context": "./",
"file": "apps/crons/Dockerfile"
},
"configurations": {
"local": {
"tags": ["siafoundation/web-crons:latest"],
"file": "apps/crons/Dockerfile",
"push": false
},
"production": {
"tags": ["ghcr.io/siafoundation/web-crons:latest"],
"file": "apps/crons/Dockerfile",
"push": true
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
Expand Down
2 changes: 1 addition & 1 deletion server/auto-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ git fetch origin
if git status | grep -q behind; then
git merge origin/main
npm ci
bash server/build-deploy.sh
bash server/nx-build.sh
fi
9 changes: 0 additions & 9 deletions server/beta-pm2.config.js

This file was deleted.

102 changes: 102 additions & 0 deletions server/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
version: '3.9'
services:
caddy:
container_name: caddy
image: ghcr.io/n8maninger/docker-caddy-cloudflare:master
restart: unless-stopped
network_mode: host
environment:
CADDY_CLOUDFLARE_TOKEN: ${CADDY_CLOUDFLARE_TOKEN}
ports:
- 80:80
- 443:443
volumes:
- /home/debian/projects/web/server/Caddyfile:/etc/caddy/Caddyfile
- /home/debian/docker/caddy/data:/data
- /home/debian/docker/caddy/config:/config
web-website:
image: ghcr.io/siafoundation/web-website
container_name: web-website
ports:
- 3001:3000
environment:
GITHUB_TOKEN: ${GITHUB_TOKEN}
NOTION_TOKEN: ${NOTION_TOKEN}
volumes:
- /home/debian/assets:/assets
restart: unless-stopped
web-website-beta:
image: ghcr.io/siafoundation/web-website
container_name: web-website-beta
ports:
- 3009:3000
environment:
GITHUB_TOKEN: ${GITHUB_TOKEN}
NOTION_TOKEN: ${NOTION_TOKEN}
volumes:
- /home/debian/assets:/assets
restart: unless-stopped
web-assets:
image: siafoundation/web-assets:latest
volumes:
- /home/debian/assets:/assets
ports:
- 3002:3000
web-crons:
image: siafoundation/web-crons:latest
volumes:
- /home/debian/assets:/assets
environment:
NOTION_TOKEN: ${NOTION_TOKEN}
web-hostd:
image: ghcr.io/siafoundation/web-hostd
container_name: web-hostd
ports:
- 3006:3000
restart: unless-stopped
web-renterd:
image: ghcr.io/siafoundation/web-renterd
container_name: web-renterd
ports:
- 3007:3000
restart: unless-stopped
web-walletd:
image: ghcr.io/siafoundation/web-walletd
container_name: web-walletd
ports:
- 3008:3000
restart: unless-stopped
web-explorer:
image: ghcr.io/siafoundation/web-explorer
container_name: web-explorer
ports:
- 3003:3000
restart: unless-stopped
web-explorer-beta:
image: siafoundation/web-explorer
container_name: web-explorer-beta
ports:
- 5005:3000
restart: unless-stopped
web-explorer-testnet-zen:
image: ghcr.io/siafoundation/web-explorer-testnet-zen
container_name: web-explorer-testnet-zen
ports:
- 3005:3000
restart: unless-stopped
host-revenue-api:
image: ghcr.io/siafoundation/host-revenue-api:master
container_name: host-revenue-api
restart: unless-stopped
ports:
- 10005:9980
volumes:
- /home/debian/docker/host-revenue-api:/data
host-revenue-api-zen:
image: ghcr.io/siafoundation/host-revenue-api:master-testnet
container_name: host-revenue-api-zen
restart: unless-stopped
ports:
- 11005:9880
volumes:
- /home/debian/docker/host-revenue-api-zen:/data
3 changes: 3 additions & 0 deletions server/docker-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -eu

docker compose up --force-recreate --pull web-website web-assets web-crons web-renterd web-hostd web-walletd web-explorer web-explorer-testnet-zen
1 change: 0 additions & 1 deletion server/build-deploy.sh → server/nx-build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash -eu

nx run-many --target=build --projects=website,assets,crons,renterd,hostd,walletd --prod
pm2 reload server/pm2.config.js
38 changes: 0 additions & 38 deletions server/pm2.config.js

This file was deleted.

0 comments on commit f55f1e5

Please sign in to comment.