mirror of
https://github.com/mirego/accent.git
synced 2024-09-11 10:55:28 +03:00
wip docker
This commit is contained in:
parent
c209a6e5d2
commit
a9d4511863
24
Dockerfile
24
Dockerfile
@ -39,12 +39,19 @@ RUN cd /opt/build && \
|
||||
rm ${APP_NAME}.tar.gz
|
||||
|
||||
COPY webapp /opt/build/webapp
|
||||
|
||||
RUN cd /opt/build && npm ci --prefix webapp --no-audit --no-color
|
||||
RUN cd /opt/build && npm run build-production --prefix webapp
|
||||
|
||||
COPY jipt /opt/build/jipt
|
||||
|
||||
RUN cd /opt/build && \
|
||||
npm ci --prefix webapp --no-audit --no-color && \
|
||||
npm ci --prefix jipt --no-audit --no-color
|
||||
RUN cd /opt/build && npm ci --prefix jipt --no-audit --no-color
|
||||
RUN cd /opt/build && npm run build-production --prefix jipt
|
||||
|
||||
RUN mv /opt/build/webapp/webapp-dist /opt/build
|
||||
RUN rm -rf /opt/build/webapp
|
||||
RUN mv /opt/build/jipt/jipt-dist /opt/build
|
||||
RUN rm -rf /opt/build/jipt
|
||||
#
|
||||
# Step 2 - Build a lean runtime container
|
||||
#
|
||||
@ -58,21 +65,24 @@ ENV APP_NAME=${APP_NAME} \
|
||||
# Update kernel and install runtime dependencies
|
||||
RUN apk --no-cache update && \
|
||||
apk --no-cache upgrade && \
|
||||
apk --no-cache add bash openssl erlang-crypto nodejs yaml-dev
|
||||
apk --no-cache add bash openssl erlang-crypto yaml-dev
|
||||
|
||||
WORKDIR /opt/accent
|
||||
WORKDIR /opt/$APP_NAME
|
||||
|
||||
# Copy the OTP binary from the build step
|
||||
COPY --from=builder /opt/build .
|
||||
|
||||
RUN cp -r /opt/$APP_NAME/webapp-dist /opt/$APP_NAME/lib/$APP_NAME-$APP_VERSION/priv/static/webapp
|
||||
RUN cp -r /opt/$APP_NAME/jipt-dist /opt/$APP_NAME/lib/$APP_NAME-$APP_VERSION/priv/static/jipt
|
||||
|
||||
# Copy the entrypoint script
|
||||
COPY priv/scripts/docker-entrypoint.sh /usr/local/bin
|
||||
RUN chmod a+x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
# Create a non-root user
|
||||
RUN adduser -D accent && chown -R accent: /opt/accent
|
||||
RUN adduser -D $APP_NAME && chown -R accent: /opt/$APP_NAME
|
||||
|
||||
USER accent
|
||||
USER $APP_NAME
|
||||
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
CMD ["foreground"]
|
||||
|
@ -5,7 +5,7 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "parcel index.html",
|
||||
"build-production": "parcel build index.ts -d ../priv/static/jipt --target browser --experimental-scope-hoisting",
|
||||
"build-production": "parcel build index.ts --out-dir=jipt-dist --target browser --experimental-scope-hoisting",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
|
@ -17,7 +17,7 @@ defmodule Accent.WebAppController do
|
||||
def index(conn, _) do
|
||||
conn
|
||||
|> put_resp_header("content-type", "text/html; charset=utf-8")
|
||||
|> send_file(:ok, conn.assigns[:file])
|
||||
|> send_resp(:ok, conn.assigns[:file])
|
||||
end
|
||||
|
||||
def ensure_file_exists(conn, _) do
|
||||
@ -32,8 +32,13 @@ defmodule Accent.WebAppController do
|
||||
|> render("maintenance.html")
|
||||
|> halt()
|
||||
|
||||
_ ->
|
||||
assign(conn, :file, file)
|
||||
{:ok, content} ->
|
||||
content = content
|
||||
|> String.replace("__WEBAPP_AUTH_PROVIDERS__", "dummy")
|
||||
|> String.replace("__API_HOST__", "http://localhost:4008")
|
||||
|> String.replace("__API_WS_HOST__", "ws://localhost:4008")
|
||||
|
||||
assign(conn, :file, content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -4,15 +4,5 @@ set -e
|
||||
# Run the migration first using the custom release task
|
||||
/opt/$APP_NAME/bin/$APP_NAME migrate
|
||||
|
||||
# Since an EmberJs app can't be built without its environment, we build it here instead of the Dockerfile.
|
||||
# This makes the image completly dependent of the deployed instance’s environment.
|
||||
cd webapp
|
||||
./node_modules/ember-cli/bin/ember build --prod --output-path=/opt/$APP_NAME/lib/$APP_NAME-$APP_VERSION/priv/static/webapp &
|
||||
cd ..
|
||||
|
||||
cd jipt
|
||||
PARCEL_WORKERS=1 ./node_modules/parcel-bundler/bin/cli.js build index.ts --experimental-scope-hoisting --out-dir=/opt/$APP_NAME/lib/$APP_NAME-$APP_VERSION/priv/static/jipt &
|
||||
cd ..
|
||||
|
||||
# Launch the OTP release and replace the caller as Process #1 in the container
|
||||
exec /opt/$APP_NAME/bin/$APP_NAME "$@"
|
||||
|
@ -6,10 +6,10 @@ import config from 'accent-webapp/config/environment';
|
||||
export default Component.extend({
|
||||
username: '',
|
||||
|
||||
googleLoginEnabled: computed(() => config.AUTH_PROVIDERS.includes('google')),
|
||||
dummyLoginEnabled: computed(() => config.AUTH_PROVIDERS.includes('dummy')),
|
||||
githubLoginEnabled: computed(() => config.AUTH_PROVIDERS.includes('github')),
|
||||
slackLoginEnabled: computed(() => config.AUTH_PROVIDERS.includes('slack')),
|
||||
googleLoginEnabled: computed(() => config.AUTH_PROVIDERS.split(',').includes('google')),
|
||||
dummyLoginEnabled: computed(() => config.AUTH_PROVIDERS.split(',').includes('dummy')),
|
||||
githubLoginEnabled: computed(() => config.AUTH_PROVIDERS.split(',').includes('github')),
|
||||
slackLoginEnabled: computed(() => config.AUTH_PROVIDERS.split(',').includes('slack')),
|
||||
|
||||
googleUrl: computed(() => `${config.API.AUTHENTICATION_PATH}/google`),
|
||||
githubUrl: computed(() => `${config.API.AUTHENTICATION_PATH}/github`),
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
module.exports = function(environment) {
|
||||
const wsHost = process.env.API_WS_HOST || 'ws://localhost:4000';
|
||||
const host = process.env.API_HOST || 'http://localhost:4000';
|
||||
const providers = (process.env.WEBAPP_AUTH_PROVIDERS || 'dummy').split(',');
|
||||
const wsHost = process.env.API_WS_HOST || '__API_WS_HOST__'
|
||||
const host = process.env.API_HOST || '__API_HOST__'
|
||||
const providers = process.env.WEBAPP_AUTH_PROVIDERS || '__WEBAPP_AUTH_PROVIDERS__'
|
||||
|
||||
const ENV = {
|
||||
modulePrefix: 'accent-webapp',
|
||||
|
@ -14,8 +14,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "ember server --port $WEBAPP_PORT",
|
||||
"build": "ember build",
|
||||
"build-production": "ember build --prod --output-path=../priv/static/webapp",
|
||||
"build": "ember build --output-path=../priv/static/webapp",
|
||||
"build-production": "ember build --prod --output-path=webapp-dist",
|
||||
"test": "ember test"
|
||||
},
|
||||
"repository": "https://github.com/mirego/accent",
|
||||
|
Loading…
Reference in New Issue
Block a user