Skip to content

Commit 03ba1be

Browse files
committed
fix: escape env variables
With this change, we avoid the problem of having to escape env variables altogether. Previously, env variables were loaded both by bash (in development) and docker-compose (in production). This meant that we had to deal with escaping in both contexts, which was the source of trouble. We resolve this by loading env vars only with bash. Close #61.
1 parent 5237332 commit 03ba1be

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

tutormfe/patches/local-docker-compose-dev-services

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,4 @@
1111
tty: true
1212
volumes:
1313
- ../plugins/mfe/apps/mfe/webpack.dev-tutor.config.js:/openedx/app/webpack.dev-tutor.config.js:ro
14-
env_file:
15-
- ../plugins/mfe/build/mfe/env/production
16-
- ../plugins/mfe/build/mfe/env/development
17-
environment:
18-
- "PORT={{ app['port'] }}"
19-
{%- for key, value in app.get("env", {}).get("production", {}).items() %}
20-
- "{{ key }}={{ value }}"
21-
{% endfor %}
22-
{%- for key, value in app.get("env", {}).get("development", {}).items() %}
23-
- "{{ key }}={{ value }}"
24-
{%- endfor %}
2514
{% endfor %}

tutormfe/templates/mfe/build/mfe/Dockerfile

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,36 @@ COPY --from={{ app["name"] }}-src /openedx/app /openedx/app
5454
COPY --from={{ app["name"] }}-i18n /openedx/app/src/i18n/messages /openedx/app/src/i18n/messages
5555
ENV PUBLIC_PATH='/{{ app["name"] }}/'
5656
EXPOSE {{ app['port'] }}
57-
CMD ["npm", "run", "start", "---", "--config", "./webpack.dev-tutor.config.js"]
5857

59-
{% endfor %}
60-
61-
{% for app in iter_values_named(suffix="MFE_APP") %}
62-
63-
######## {{ app["name"] }} (production)
64-
FROM {{ app["name"] }}-dev AS {{ app["name"] }}
6558
COPY ./env/production /openedx/env/production
6659
RUN touch /openedx/env/production.override \
6760
{%- for key, value in app.get("env", {}).get("production", {}).items() %}
6861
&& echo "{{ key }}='{{ value }}'" >> /openedx/env/production.override \
6962
{%- endfor %}
7063
&& echo "done setting production overrides"
71-
RUN bash -c "set -a && source /openedx/env/production && source /openedx/env/production.override && npm run build"
64+
COPY ./env/development /openedx/env/development
65+
RUN touch /openedx/env/development.override \
66+
{%- for key, value in app.get("env", {}).get("development", {}).items() %}
67+
&& echo "{{ key }}='{{ value }}'" >> /openedx/env/development.override \
68+
{%- endfor %}
69+
&& echo "done setting development overrides"
70+
71+
CMD ["/bin/bash", "-c", "set -a && \
72+
source /openedx/env/production && \
73+
source /openedx/env/production.override && \
74+
source /openedx/env/development && \
75+
source /openedx/env/development.override && \
76+
npm run start --- --config ./webpack.dev-tutor.config.js"]
77+
{% endfor %}
78+
79+
{% for app in iter_values_named(suffix="MFE_APP") %}
80+
81+
######## {{ app["name"] }} (production)
82+
FROM {{ app["name"] }}-dev AS {{ app["name"] }}
83+
RUN bash -c "set -a && \
84+
source /openedx/env/production && \
85+
source /openedx/env/production.override && \
86+
npm run build"
7287

7388
{% endfor %}
7489

tutormfe/templates/mfe/build/mfe/env/production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ NODE_ENV=production
1919
PUBLISHER_BASE_URL=
2020
REFRESH_ACCESS_TOKEN_ENDPOINT={% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/login_refresh
2121
SEGMENT_KEY=
22-
SITE_NAME={{ PLATFORM_NAME|replace("'", "'\\''")|replace(" ", "\ ") }}
22+
SITE_NAME="{{ PLATFORM_NAME }}"
2323
STUDIO_BASE_URL={{ "https" if ENABLE_HTTPS else "http" }}://{{ CMS_HOST }}
2424
USER_INFO_COOKIE_NAME=user-info
2525

0 commit comments

Comments
 (0)