Skip to content

Commit c5d1adc

Browse files
committed
Make quick launch faster
1 parent 43c0c32 commit c5d1adc

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

.github/workflows/DiploiBuild.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ env:
1313
INITIAL_PROJECT_IMAGE_NAME: ${{ github.repository }}-initial-project
1414
DEMO_TARGET_REPOSITORY: 'https://x-access-token:${{ secrets.DEMO_REPOSITORY_PAT }}@github.com/${{ github.repository }}-demo.git'
1515
DEMO_TAG_NAME: '${GITHUB_REF#refs/tags/}'
16-
TAG_NAME: '${GITHUB_REF#refs/tags/}'
1716

1817
jobs:
1918

InitialProjectDockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ FROM ghcr.io/diploi/astro-template
44
WORKDIR /app
55
COPY initialProject .
66

7-
RUN npm install
8-
RUN npm run build
7+
# Create production build
8+
RUN npm install && npm run build
9+
10+
# For quick launch
11+
RUN git clone https://github.com/diploi/astro-template-demo.git /app-quick-launch \
12+
&& npm install --prefix /app-quick-launch

diploi-runonce.sh

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,51 @@ if [ ! "$(ls -A /app)" ]; then
2828
# Generate root ssh key
2929
ssh-keygen -A;
3030

31-
progress "Pulling code";
32-
33-
git init --initial-branch=main
34-
git config credential.helper '!diploi-credential-helper';
35-
git remote add --fetch origin $REPOSITORY_URL;
36-
if [ -z "$REPOSITORY_TAG" ]; then
37-
git checkout -f $REPOSITORY_BRANCH;
31+
if [ "$REPOSITORY_URL" = "https://github.com/diploi/astro-template-demo.git" ]; then
32+
# Using quick launch cached initial files
33+
progress "Using quick launch cache start";
34+
find /app-quick-launch/ -mindepth 1 -maxdepth 1 -exec mv -t /app -- {} +
35+
rmdir /app-quick-launch
36+
progress "Using quick launch cache done";
3837
else
39-
git checkout -f -q $REPOSITORY_TAG;
40-
git checkout -b main
41-
git branch --set-upstream-to=origin/main main
38+
progress "Pulling code";
39+
git init --initial-branch=main
40+
git config credential.helper '!diploi-credential-helper';
41+
git remote add --fetch origin $REPOSITORY_URL;
42+
if [ -z "$REPOSITORY_TAG" ]; then
43+
git checkout -f $REPOSITORY_BRANCH;
44+
else
45+
git checkout -f -q $REPOSITORY_TAG;
46+
git checkout -b main
47+
git branch --set-upstream-to=origin/main main
48+
fi
49+
git remote set-url origin "$REPOSITORY_URL";
50+
git config --unset credential.helper;
51+
52+
progress "Installing";
53+
npm install;
4254
fi
43-
git remote set-url origin "$REPOSITORY_URL";
44-
git config --unset credential.helper;
4555

4656
# Configure VSCode
4757
mkdir -p /root/.local/share/code-server/User
4858
cp /usr/local/etc/diploi-vscode-settings.json /root/.local/share/code-server/User/settings.json
49-
50-
progress "Installing";
51-
npm install;
59+
# TODO: How to update these if env changes?
60+
cat > /app/.vscode/settings.json << EOL
61+
{
62+
"sqltools.connections": [
63+
{
64+
"previewLimit": 50,
65+
"server": "$POSTGRES_HOST",
66+
"port": $POSTGRES_PORT,
67+
"driver": "PostgreSQL",
68+
"name": "PostgreSQL",
69+
"database": "$POSTGRES_DB",
70+
"username": "$POSTGRES_USER",
71+
"password": "$POSTGRES_PASSWORD",
72+
}
73+
]
74+
}
75+
EOL
5276

5377
fi
5478

@@ -59,6 +83,7 @@ update-ca-certificates
5983
env >> /etc/environment
6084

6185
# Now that everything is initialized, start all services
86+
progress "Starting services";
6287
supervisorctl start www
6388
supervisorctl start code-server
6489

0 commit comments

Comments
 (0)