-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #509 from TAMULib/staging
September Components Sprint
- Loading branch information
Showing
47 changed files
with
313 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,73 @@ | ||
FROM node:16-slim as npm | ||
# Settings. | ||
ARG USER_ID=3001 | ||
ARG USER_NAME=components | ||
ARG SOURCE_DIR=/$USER_NAME/source | ||
ARG NPM_REGISTRY=upstream | ||
ARG NODE_ENV=development | ||
|
||
COPY package.json ./ | ||
# Node stage. | ||
FROM node:lts-slim as build | ||
ARG USER_ID | ||
ARG USER_NAME | ||
ARG SOURCE_DIR | ||
ARG NPM_REGISTRY | ||
ARG NODE_ENV | ||
|
||
WORKDIR /app | ||
COPY . . | ||
ENV NODE_ENV=$NODE_ENV | ||
|
||
RUN npm install | ||
RUN npm run build | ||
# Create the user and group (use a high ID to attempt to avoid conflicts). | ||
RUN groupadd --non-unique -g $USER_ID $USER_NAME && \ | ||
useradd --non-unique -d /$USER_NAME -m -u $USER_ID -g $USER_ID $USER_NAME | ||
|
||
FROM httpd:2.4-alpine | ||
# Update the system and install dependencies (iproute2 is needed for "ip"). | ||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt install iproute2 -y && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy in files from outside of docker. | ||
COPY . $SOURCE_DIR | ||
|
||
# Ensure required file permissions. | ||
RUN chown -R $USER_ID:$USER_ID $SOURCE_DIR | ||
|
||
# Set deployment directory. | ||
WORKDIR $SOURCE_DIR | ||
|
||
# Login as user. | ||
USER $USER_NAME | ||
|
||
# Perform actions. | ||
RUN echo $NPM_REGISTRY && \ | ||
bash build/docker-npmrc.sh $NPM_REGISTRY && \ | ||
npm install && \ | ||
npm run build | ||
|
||
# Apache stage. | ||
FROM httpd:2.4-alpine | ||
ARG SOURCE_DIR | ||
ARG MAJOR_VERSION=0x | ||
ARG MAJOR_MINOR_VERSION=0.0 | ||
|
||
COPY --from=npm /app/dist/bundle/ /usr/local/apache2/htdocs/wvr-components/bundle | ||
|
||
RUN ln -s /usr/local/apache2/htdocs/wvr-components/bundle /usr/local/apache2/htdocs/wvr-components/latest | ||
RUN ln -s /usr/local/apache2/htdocs/wvr-components/bundle /usr/local/apache2/htdocs/wvr-components/${MAJOR_VERSION}x | ||
RUN ln -s /usr/local/apache2/htdocs/wvr-components/bundle /usr/local/apache2/htdocs/wvr-components/${MAJOR_MINOR_VERSION} | ||
COPY --from=build $SOURCE_DIR/dist/bundle/ /usr/local/apache2/htdocs/wvr-components/bundle | ||
COPY --from=build $SOURCE_DIR/src/config-template.json tmp/config-template.json | ||
|
||
COPY --from=npm /app/src/config-template.json tmp/config-template.json | ||
COPY docker-entrypoint /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/docker-entrypoint | ||
RUN ln -s /usr/local/apache2/htdocs/wvr-components/bundle /usr/local/apache2/htdocs/wvr-components/latest && \ | ||
ln -s /usr/local/apache2/htdocs/wvr-components/bundle /usr/local/apache2/htdocs/wvr-components/${MAJOR_VERSION}x && \ | ||
ln -s /usr/local/apache2/htdocs/wvr-components/bundle /usr/local/apache2/htdocs/wvr-components/${MAJOR_MINOR_VERSION} | ||
|
||
ENTRYPOINT ["docker-entrypoint"] | ||
COPY build/docker-entrypoint.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
|
||
RUN apk update; | ||
RUN apk upgrade; | ||
ENTRYPOINT ["docker-entrypoint.sh"] | ||
|
||
RUN echo "" >> /usr/local/apache2/conf/httpd.conf | ||
RUN echo "###SPECIFIC CUSTOMIZATIONS###" >> /usr/local/apache2/conf/httpd.conf | ||
RUN echo "" >> /usr/local/apache2/conf/httpd.conf | ||
RUN apk update && \ | ||
apk upgrade | ||
|
||
RUN printf '<Directory /usr/local/apache2/htdocs> \nOrder Allow,Deny \nAllow from all \nAllowOverride all \nHeader set Access-Control-Allow-Origin "*" \n</Directory>' >> /usr/local/apache2/conf/httpd.conf | ||
RUN echo "" >> /usr/local/apache2/conf/httpd.conf && \ | ||
echo "###SPECIFIC CUSTOMIZATIONS###" >> /usr/local/apache2/conf/httpd.conf && \ | ||
echo "" >> /usr/local/apache2/conf/httpd.conf && \ | ||
printf '<Directory /usr/local/apache2/htdocs> \nOrder Allow,Deny \nAllow from all \nAllowOverride all \nHeader set Access-Control-Allow-Origin "*" \n</Directory>' >> /usr/local/apache2/conf/httpd.conf | ||
|
||
CMD ["httpd", "-D", "FOREGROUND"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
# Requires ip and awk, but only for docker-linux. | ||
|
||
main() { | ||
if [[ $1 == "docker-linux" ]] ; then | ||
to_npmrc $(ip route | awk '/^default via/ { print $3 }') | ||
elif [[ $1 == "docker-windows" || $1 == "docker-mac" ]] ; then | ||
to_npmrc host.docker.internal | ||
fi | ||
} | ||
|
||
to_npmrc() { | ||
echo "Setting NPM registry to '$1'." | ||
echo "registry=http://$1:4873" >> .npmrc | ||
} | ||
|
||
main "$@" |
Oops, something went wrong.