Skip to content

Commit bbbfdcd

Browse files
committed
feat(frontend): Use a single docker image with configurable environment at runtime
1 parent c87196b commit bbbfdcd

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

docker-compose.local.producers.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ services:
1212

1313
frontend:
1414
container_name: frontend
15-
image: openmina/frontend:0.8.3-producer-demo
16-
# build:
17-
# context: .
18-
# dockerfile: Dockerfile_FE
19-
# args:
20-
# BUILD_CONFIGURATION: block_producers
15+
image: openmina/frontend:0.8.3
16+
environment:
17+
OPENMINA_FRONTEND_ENVIRONMENT: block_producers
2118
ports:
2219
- "8070:80"

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ services:
1111

1212
frontend:
1313
image: openmina/frontend:${OPENMINA_FRONTEND_TAG:-latest}
14+
environment:
15+
OPENMINA_FRONTEND_ENVIRONMENT: compose
1416
ports:
1517
- "8070:80"

frontend/Dockerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM node:18 AS BUILD_IMAGE
22
# Doesn't matter what we put here - it get's overwritten by the docker build command
3-
ARG BUILD_CONFIGURATION=staging
3+
ARG BUILD_CONFIGURATION=production
44
WORKDIR /app
55
COPY . .
66
RUN npm install
@@ -12,6 +12,10 @@ RUN echo "---------- USING APACHE ----------"
1212
FROM httpd:2.4
1313
COPY --from=BUILD_IMAGE /app/dist/frontend /usr/local/apache2/htdocs/
1414
COPY --from=BUILD_IMAGE /app/httpd.conf /usr/local/apache2/conf/httpd.conf
15-
#FROM nginx:alpine
16-
#COPY --from=BUILD_IMAGE /app/dist/frontend /usr/share/nginx/html
17-
#COPY --from=BUILD_IMAGE /app/nginx.conf /etc/nginx/nginx.conf
15+
16+
COPY docker/startup.sh /usr/local/bin/startup.sh
17+
RUN chmod +x /usr/local/bin/startup.sh
18+
19+
ENTRYPOINT ["/usr/local/bin/startup.sh"]
20+
21+
CMD ["httpd-foreground"]

frontend/docker/startup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
if [ -n "$OPENMINA_FRONTEND_ENVIRONMENT" ]; then
4+
echo "Using environment: $OPENMINA_FRONTEND_ENVIRONMENT"
5+
cp -f /usr/local/apache2/htdocs/assets/environments/"$OPENMINA_FRONTEND_ENVIRONMENT".js \
6+
/usr/local/apache2/htdocs/assets/environments/env.js
7+
else
8+
echo "No environment specified. Using default."
9+
fi
10+
11+
echo "Starting Apache..."
12+
exec "$@"

0 commit comments

Comments
 (0)