Skip to content

Commit a1f5a97

Browse files
authored
task(docker): docker-compose with FE (#332)
- separate FE environment for compose - nginx reverse proxy for node - compose with default network - FE image build with GHA - tags for docker images
1 parent c6005db commit a1f5a97

File tree

7 files changed

+163
-26
lines changed

7 files changed

+163
-26
lines changed

.github/workflows/docker.yaml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ on:
33
workflow_dispatch: {}
44
push:
55
branches: [ main, develop ]
6+
tags: [ "*" ]
67
paths-ignore:
78
# - ".github/**"
89
- ".drone.yml"
910
- "helm/**"
1011
- "*.md"
1112
- "docs/**"
1213

13-
14-
1514
jobs:
16-
docker-build:
15+
build-openmina-node-image:
1716
runs-on: ubuntu-latest
1817
steps:
1918
- name: Git checkout
@@ -39,6 +38,9 @@ jobs:
3938
tags: |
4039
type=ref,event=branch
4140
type=sha,format=short
41+
type=semver,pattern={{version}},event=tag
42+
type=ref,event=tag
43+
type=raw,value=latest,enable={{is_default_branch}}
4244
4345
- name: Build and push
4446
uses: docker/build-push-action@v5
@@ -48,3 +50,44 @@ jobs:
4850
tags: ${{ steps.meta.outputs.tags }}
4951
cache-from: type=gha
5052
cache-to: type=gha,mode=max
53+
54+
build-openmina-frontend-image:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Git checkout
58+
uses: actions/checkout@v3
59+
60+
- name: Login to Docker Hub
61+
uses: docker/login-action@v3
62+
with:
63+
username: ${{ secrets.DOCKERHUB_USERNAME }}
64+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
65+
66+
- name: Set up Docker Buildx
67+
uses: docker/setup-buildx-action@v3
68+
69+
- name: Docker meta
70+
id: meta
71+
uses: docker/metadata-action@v5
72+
with:
73+
# list of Docker images to use as base name for tags
74+
images: |
75+
openmina/frontend
76+
# generate Docker tags based on the following events/attributes
77+
tags: |
78+
type=ref,event=branch
79+
type=sha,format=short
80+
type=semver,pattern={{version}},event=tag
81+
type=ref,event=tag
82+
type=raw,value=latest,enable={{is_default_branch}}
83+
84+
- name: Build and push
85+
uses: docker/build-push-action@v5
86+
with:
87+
context: ./frontend
88+
build-args: |
89+
BUILD_CONFIGURATION=compose
90+
push: true
91+
tags: ${{ steps.meta.outputs.tags }}
92+
cache-from: type=gha
93+
cache-to: type=gha,mode=max

docker-compose.dev.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '3.8'
2+
3+
services:
4+
openmina_node:
5+
build:
6+
context: ./
7+
dockerfile: Dockerfile
8+
command: [ "node" ]
9+
ports:
10+
- "3000:3000"
11+
environment:
12+
- MINA_SNARK_WORKER_TAG=0.0.9
13+
networks:
14+
- app-network
15+
16+
frontend:
17+
build:
18+
context: ./
19+
dockerfile: Dockerfile_FE
20+
args:
21+
BUILD_CONFIGURATION: local
22+
ports:
23+
- "8070:80"
24+
networks:
25+
- app-network
26+
27+
networks:
28+
app-network:
29+
driver: bridge

docker-compose.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
11
version: '3.8'
22

33
services:
4-
openmina_node:
5-
build:
6-
context: ./
7-
dockerfile: Dockerfile
4+
openmina-node:
5+
image: openmina/openmina:${OPENMINA_TAG:-latest}
86
command: [ "node" ]
97
ports:
108
- "3000:3000"
119
environment:
1210
- MINA_SNARK_WORKER_TAG=0.0.9
13-
networks:
14-
- app-network
1511

1612
frontend:
17-
build:
18-
context: ./
19-
dockerfile: Dockerfile_FE
20-
args:
21-
BUILD_CONFIGURATION: local
13+
image: openmina/frontend:${OPENMINA_FRONTEND_TAG:-latest}
2214
ports:
2315
- "8070:80"
24-
networks:
25-
- app-network
26-
27-
networks:
28-
app-network:
29-
driver: bridge

frontend/Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@
5050
#COPY nginx.conf .
5151
#RUN cat nginx.conf
5252

53-
5453
FROM node:18 AS BUILD_IMAGE
54+
ARG BUILD_CONFIGURATION=production
5555
WORKDIR /app
56-
COPY dist/ ./dist/
57-
COPY nginx.conf .
58-
#RUN npm install
59-
#RUN node_modules/.bin/ng build --configuration production
60-
#RUN npm prune --production
56+
COPY . .
57+
RUN npm install
58+
RUN node_modules/.bin/ng build --configuration ${BUILD_CONFIGURATION}
59+
RUN npm prune --production
60+
RUN [ -f nginx.${BUILD_CONFIGURATION}.conf ] && cp nginx.${BUILD_CONFIGURATION}.conf nginx.conf
61+
6162
FROM nginx:alpine
6263
RUN pwd
6364
RUN ls -l

frontend/angular.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@
8181
}
8282
],
8383
"outputHashing": "all"
84+
},
85+
"compose": {
86+
"fileReplacements": [
87+
{
88+
"replace": "src/environments/environment.ts",
89+
"with": "src/environments/environment.compose.ts"
90+
}
91+
],
92+
"outputHashing": "all"
8493
}
8594
},
8695
"defaultConfiguration": "production"

frontend/nginx.compose.conf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
user nginx;
2+
worker_processes auto;
3+
4+
error_log /var/log/nginx/error.log notice;
5+
pid /var/run/nginx.pid;
6+
7+
8+
events {
9+
worker_connections 1024;
10+
}
11+
12+
13+
http {
14+
15+
server {
16+
location / {
17+
root /usr/share/nginx/html;
18+
try_files $uri $uri/ /index.html;
19+
index index.html index.htm;
20+
error_page 404 /usr/share/nginx/html/index.html;
21+
}
22+
23+
location /openmina-node {
24+
rewrite_log on;
25+
rewrite ^/openmina-node/(.*) /$1 break;
26+
proxy_pass http://openmina-node:3000;
27+
}
28+
}
29+
30+
include /etc/nginx/mime.types;
31+
default_type application/octet-stream;
32+
large_client_header_buffers 4 32k;
33+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
34+
'$status $body_bytes_sent "$http_referer" '
35+
'"$http_user_agent" "$http_x_forwarded_for"';
36+
37+
access_log /var/log/nginx/access.log main;
38+
39+
sendfile on;
40+
#tcp_nopush on;
41+
42+
keepalive_timeout 65;
43+
44+
#gzip on;
45+
46+
# include /etc/nginx/conf.d/*.conf;
47+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { MinaEnv } from '@shared/types/core/environment/mina-env.type';
2+
3+
export const environment: Readonly<MinaEnv> = {
4+
production: false,
5+
identifier: 'Local FE',
6+
globalConfig: {
7+
features: {
8+
dashboard: [],
9+
nodes: ['overview', 'live', 'bootstrap'],
10+
state: ['actions'],
11+
network: ['node-dht', 'graph-overview', 'bootstrap-stats'],
12+
snarks: ['scan-state'],
13+
},
14+
},
15+
configs: [
16+
{
17+
name: 'Compose rust node',
18+
url: '/openmina-node',
19+
},
20+
],
21+
};
22+

0 commit comments

Comments
 (0)