mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-05 03:05:40 -05:00
* feat(docker): build and use client and api images
* feat: always use .env
dotenv fails without throwing if the .env file is missing and never
overwrites variables if they already exist. As such, we can use it in
build pipelines.
* fix: remove quotes from env vars
dotenv normalises quoted and unquoted strings (X=x, X='x' and
X="x") all become the same .env object {X: 'x'}. However, Docker's
env_file does not (the three cases are distinct). As a result, we
should use unquoted strings for consistency.
* fix: provide custom warning when .env is missing
* feat(docker): include client-config
* fix(docker): remove build packages from api image
* fix(docker): run script from correct dir
* fix(docker): correct permissions and dests
* fix(docker): consolidate run steps
This is standard practice, but did not have a noticable affect on the
image size
* fix(docker): clean the npm cache
Prior to this step the image was 1.11GB uncompressed and we got a modest
saving, 1.09GB after.
* refactor(docker): regexless COPY directives
* feat(docker): use alpine
This shrinks the image down to 259MB
* fix(docker): update build scripts
* fix: correct the server Dockerfile RUNs
* DEBUG: expose mysql port for seeding
* chore: update client Dockerfile's node versions
* fix: remove executable permissions from index.js
It's not a cli, so I don't think it needs to be executable.
* chore: update node and remove stale comments
* feat: use ENTRYPOINT + CMD to allow runtime config
* fix: add CURRICULUM_LOCALE arg
* feat: allow client port configuration
* feat: allow api port to be configured
* refactor: use unique variable names for ports
* fix: add default CLIENT_PORT
* refactor: clean up
41 lines
1.1 KiB
Docker
41 lines
1.1 KiB
Docker
FROM node:14.16.1-buster AS builder
|
|
|
|
# this is a bit clunky, perhaps there's a more concise way of passing in build
|
|
# arguments
|
|
ARG FREECODECAMP_NODE_ENV
|
|
ARG HOME_LOCATION
|
|
ARG API_LOCATION
|
|
ARG FORUM_LOCATION
|
|
ARG NEWS_LOCATION
|
|
ARG CLIENT_LOCALE
|
|
ARG CURRICULUM_LOCALE
|
|
ARG STRIPE_PUBLIC_KEY
|
|
ARG ALGOLIA_APP_ID
|
|
ARG ALGOLIA_API_KEY
|
|
ARG PAYPAL_CLIENT_ID
|
|
ARG DEPLOYMENT_ENV
|
|
ARG SHOW_UPCOMING_CHANGES
|
|
|
|
# node images create a non-root user that we can use
|
|
USER node
|
|
WORKDIR /home/node/build
|
|
COPY --chown=node:node . .
|
|
RUN npm ci
|
|
# we don't need to separately run ensure-env, since it gets called as part of
|
|
# build:client
|
|
RUN npm run build:client
|
|
|
|
WORKDIR /home/node/config
|
|
RUN git clone https://github.com/freeCodeCamp/client-config.git client
|
|
|
|
FROM node:14.16.1-alpine
|
|
RUN npm i -g serve
|
|
USER node
|
|
WORKDIR /home/node
|
|
COPY --from=builder /home/node/build/client/public/ client/public
|
|
COPY --from=builder /home/node/config/client/serve.json client
|
|
COPY --from=builder /home/node/config/client/www/ client
|
|
|
|
ENTRYPOINT ["serve", "-c", "../serve.json", "client/public"]
|
|
CMD ["-l", "8000"]
|