Skip to content

Commit

Permalink
ci: contenerized web and mobile
Browse files Browse the repository at this point in the history
Mobile contenerization requires to specify your computer
IP address to make it possible to use expo go.
  • Loading branch information
raczu committed Apr 2, 2024
1 parent 738a3bd commit 615f28b
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# MOBILE
MOBILE_LISTEN_PORT=5274
RCT_METRO_PORT=5274
REACT_NATIVE_PACKAGER_HOSTNAME=YOUR_IP_ADDRESS

# WEB
WEB_LISTEN_PORT=5273

# SERVER
ASPNETCORE_ENVIRONMENT=Development

Expand Down
34 changes: 34 additions & 0 deletions Client/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
LICENSE
README.md
22 changes: 22 additions & 0 deletions Client/mobile.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:21.7.1-alpine as base

FROM base as prunner
RUN apk add --no-cache libc6-compat
copy reasn-client /source
WORKDIR /source
RUN yarn set version 4.1.0 \
&& yarn dlx turbo prune native --docker

FROM base AS installer
RUN apk add --no-cache libc6-compat
WORKDIR /source
COPY --from=prunner /source/out/json/ .
COPY --from=prunner /source/out/yarn.lock ./yarn.lock
RUN --mount=type=cache,target=.yarn/cache \
yarn install --immutable
COPY --from=prunner /source/out/full .

FROM installer AS development
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
CMD ["yarn", "run", "dev:mobile"]
22 changes: 22 additions & 0 deletions Client/web.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:21.7.1-alpine as base

FROM base as prunner
RUN apk add --no-cache libc6-compat
copy reasn-client /source
WORKDIR /source
RUN yarn set version 4.1.0 \
&& yarn dlx turbo prune web --docker

FROM base AS installer
RUN apk add --no-cache libc6-compat
WORKDIR /source
COPY --from=prunner /source/out/json/ .
COPY --from=prunner /source/out/yarn.lock ./yarn.lock
RUN --mount=type=cache,target=.yarn/cache \
yarn install --immutable
COPY --from=prunner /source/out/full .

FROM installer AS development
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
CMD ["yarn", "run", "dev:web"]
41 changes: 39 additions & 2 deletions compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
services:
mobile:
build:
context: Client
dockerfile: mobile.Dockerfile
target: development
restart: unless-stopped
networks:
- reasn-network
ports:
- "${MOBILE_LISTEN_PORT:-8081}:${MOBILE_LISTEN_PORT:-8081}"
env_file:
- .env
depends_on:
- server
develop:
watch:
- action: rebuild
path: ./Client/reasn-client/yarn.lock
- action: sync
path: ./Client/reasn-client/apps/native
target: /source/apps/native
- action: sync
path: ./Client/reasn-client/packages
target: /source/packages

web:
build:
target: development
develop:
watch:
- action: rebuild
path: ./Client/reasn-client/yarn.lock
- action: sync
path: ./Client/reasn-client/apps/web
target: /source/apps/web
- action: sync
path: ./Client/reasn-client/packages
target: /source/packages

server:
build:
target: development
Expand All @@ -8,8 +47,6 @@ services:
path: ./Server/ReasnAPI/ReasnAPI

postgres:
expose:
- 5432
volumes:
- ./Database/init-dev-data.sql:/docker-entrypoint-initdb.d/03-init-dev-data.sql

23 changes: 21 additions & 2 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
services:
web:
build:
context: Client
dockerfile: web.Dockerfile
restart: unless-stopped
networks:
- reasn-network
ports:
- "${WEB_LISTEN_PORT:-5273}:3000"
env_file:
- .env
depends_on:
- server

server:
build:
context: Server
dockerfile: server.Dockerfile
target: production
restart: unless-stopped
networks:
- reasn-isolated-network
- reasn-network
ports:
- "${SERVER_LISTEN_PORT:-5272}:8080"
Expand All @@ -18,7 +34,7 @@ services:
image: postgres:16
restart: unless-stopped
networks:
- reasn-network
- reasn-isolated-network
volumes:
- postgres-data:/var/lib/postgresql/data
- ./Database/init-db.sql:/docker-entrypoint-initdb.d/01-init-db.sql
Expand All @@ -34,8 +50,9 @@ services:

pgadmin:
image: dpage/pgadmin4:8.0
restart: unless-stopped
networks:
- reasn-network
- reasn-isolated-network
ports:
- "${PGADMIN_LISTEN_PORT:-5050}:${PGADMIN_LISTEN_PORT:-80}"
volumes:
Expand All @@ -47,6 +64,8 @@ services:
condition: service_healthy

networks:
reasn-isolated-network:
driver: bridge
reasn-network:
driver: bridge

Expand Down

0 comments on commit 615f28b

Please sign in to comment.