Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
Parisa Samimi committed Mar 21, 2024
1 parent d834987 commit de71aa9
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ MONGO_PORT=27017
MONGO_DATABASE_NAME=blog

## frontend
API_BASE_URL=http://127.0.0.1:8000
INTERNAL_API_BASE_URL=http://app
NUXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8000
NUXT_INTERNAL_API_BASE_URL=http://app
9 changes: 0 additions & 9 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
FROM golang:1.21 as build

WORKDIR /dist
COPY . .

# Adjust the ARCH if needed - eg amd64 or arm64v8
ENV GOARCH=amd64 CGO_ENABLED=0

RUN go mod download

# Build the binary
RUN go build -v -o app ./main.go && chmod +x app

FROM alpine:latest as production

COPY --from=build /dist /usr/bin

EXPOSE 80

CMD ["app", "serve", "-port=80"]
7 changes: 4 additions & 3 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ services:
build:
context: ./frontend
dockerfile: Dockerfile
target: develop
depends_on:
- app
ports:
- "3000:3000"
volumes:
- ./frontend:/app
- ./frontend:/opt/app
environment:
API_BASE_URL: ${API_BASE_URL}
INTERNAL_API_BASE_URL: ${INTERNAL_API_BASE_URL}
NUXT_PUBLIC_API_BASE_URL: ${NUXT_PUBLIC_API_BASE_URL}
NUXT_INTERNAL_API_BASE_URL: ${NUXT_INTERNAL_API_BASE_URL}
command: >
sh -c "npm install; npm run dev --host"
Expand Down
18 changes: 12 additions & 6 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
FROM node:21.6-alpine3.18

WORKDIR /app

FROM node:20.11-alpine AS base
WORKDIR /opt/app
COPY . .

RUN npm install

FROM base AS develop
EXPOSE 3000
CMD ["npm", "run", "dev", '--host']

CMD npm run dev --host
FROM base as build
RUN npm run build

FROM node:20.11-alpine as production
WORKDIR /opt/app
COPY --from=build /opt/app/.output .
EXPOSE 3000
CMD ["node", "server/index.mjs"]
4 changes: 2 additions & 2 deletions frontend/composables/urlResolver.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function baseUrl() {
const {internalApiBaseUrl, public: p} = useRuntimeConfig()
const url = process.client ? p.publicApiBaseUrl : internalApiBaseUrl;
const url = process.client ? p.apiBaseUrl : internalApiBaseUrl;

return {
publicApiBaseUrl: p.publicApiBaseUrl.replace(/\/$/, ""),
publicApiBaseUrl: p.apiBaseUrl.replace(/\/$/, ""),
internalApiBaseUrl: internalApiBaseUrl?.replace(/\/$/, ""),
apiBaseUrl: url.replace(/\/$/, "")
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export default defineNuxtConfig({
'@vueuse/nuxt','@pinia/nuxt'
],
runtimeConfig: {
internalApiBaseUrl: process.env.INTERNAL_API_BASE_URL,
internalApiBaseUrl: '',
public: {
publicApiBaseUrl: process.env.API_BASE_URL,
apiBaseUrl: '',
}
}
})
5 changes: 0 additions & 5 deletions frontend/plugins/axios.js

This file was deleted.

0 comments on commit de71aa9

Please sign in to comment.